|
@@ -4,7 +4,9 @@ namespace App\Models\Product; |
|
@@ -4,7 +4,9 @@ namespace App\Models\Product; |
|
4
|
|
4
|
|
|
5
|
use App\Helper\Arr;
|
5
|
use App\Helper\Arr;
|
|
6
|
use App\Models\Base;
|
6
|
use App\Models\Base;
|
|
|
|
7
|
+use App\Models\File\Image;
|
|
7
|
use App\Models\RouteMap;
|
8
|
use App\Models\RouteMap;
|
|
|
|
9
|
+use App\Services\CosService;
|
|
8
|
use App\Services\Facades\Upload;
|
10
|
use App\Services\Facades\Upload;
|
|
9
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
11
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
10
|
|
12
|
|
|
@@ -36,7 +38,32 @@ class Product extends Base |
|
@@ -36,7 +38,32 @@ class Product extends Base |
|
36
|
$value['url'] = Upload::url2path($value['url']);
|
38
|
$value['url'] = Upload::url2path($value['url']);
|
|
37
|
$this->attributes['thumb'] = Arr::a2s($value);
|
39
|
$this->attributes['thumb'] = Arr::a2s($value);
|
|
38
|
}
|
40
|
}
|
|
|
|
41
|
+ /**
|
|
|
|
42
|
+ * @remark :获取图片链接
|
|
|
|
43
|
+ * @name :getImageUrl
|
|
|
|
44
|
+ * @author :lyh
|
|
|
|
45
|
+ * @method :post
|
|
|
|
46
|
+ * @time :2023/7/20 16:46
|
|
|
|
47
|
+ */
|
|
|
|
48
|
+ public function getImageUrl($hash){
|
|
|
|
49
|
+ if(is_array($hash)){
|
|
|
|
50
|
+ $url = [];
|
|
|
|
51
|
+ foreach ($hash as $k => $v){
|
|
|
|
52
|
+ $url['images_link'][$k] = $this->getImageUrl($v);
|
|
|
|
53
|
+ }
|
|
|
|
54
|
+ }else{
|
|
|
|
55
|
+ $imageModel = new Image();
|
|
|
|
56
|
+ $info = $imageModel->read(['hash'=>$hash]);
|
|
|
|
57
|
+ if($info['is_cos'] == 1){
|
|
|
|
58
|
+ $cos = new CosService();
|
|
|
|
59
|
+ $url = $cos->getImageUrl($info['path']);
|
|
|
|
60
|
+ }else{
|
|
|
|
61
|
+ $url = url('b/image/'.$info['hash']);
|
|
|
|
62
|
+ }
|
|
|
|
63
|
+ }
|
|
39
|
|
64
|
|
|
|
|
65
|
+ return $url;
|
|
|
|
66
|
+ }
|
|
40
|
public function getThumbAttribute($value){
|
67
|
public function getThumbAttribute($value){
|
|
41
|
$value = Arr::s2a($value);
|
68
|
$value = Arr::s2a($value);
|
|
42
|
$value['url'] = Upload::path2url($value['url']);
|
69
|
$value['url'] = Upload::path2url($value['url']);
|