作者 lyh

gx

@@ -334,7 +334,7 @@ class FileController @@ -334,7 +334,7 @@ class FileController
334 } 334 }
335 335
336 /** 336 /**
337 - * @remark :获取文件交接链接 337 + * @remark :获取文件链接
338 * @name :getImageUrl 338 * @name :getImageUrl
339 * @author :lyh 339 * @author :lyh
340 * @method :post 340 * @method :post
@@ -297,7 +297,7 @@ class ImageController extends Controller @@ -297,7 +297,7 @@ class ImageController extends Controller
297 */ 297 */
298 public function getImageList(){ 298 public function getImageList(){
299 $imageModel = new ImageModel(); 299 $imageModel = new ImageModel();
300 - $lists = $imageModel->list([],$order = 'id',['id','hash','type','path','created_at']); 300 + $lists = $imageModel->list($this->param,$order = 'id',['id','hash','type','path','created_at']);
301 foreach ($lists as $k => $v){ 301 foreach ($lists as $k => $v){
302 $v['image_link'] = $this->getImageUrl($v['hash']); 302 $v['image_link'] = $this->getImageUrl($v['hash']);
303 $lists[$k] = $v; 303 $lists[$k] = $v;
@@ -45,6 +45,13 @@ class ProductRequest extends FormRequest @@ -45,6 +45,13 @@ class ProductRequest extends FormRequest
45 } 45 }
46 } 46 }
47 }], 47 }],
  48 + 'icon' => ['required', 'array', function ($attribute, $value, $fail) {
  49 + foreach ($value as $v) {
  50 + if (empty($v['url'])) {
  51 + $fail('图片链接不能为空');
  52 + }
  53 + }
  54 + }],
48 'attrs' => ['array', function ($attribute, $value, $fail) { 55 'attrs' => ['array', function ($attribute, $value, $fail) {
49 foreach ($value as $v) { 56 foreach ($value as $v) {
50 if (empty($v['key'])) { 57 if (empty($v['key'])) {
@@ -32,10 +32,9 @@ class Product extends Base @@ -32,10 +32,9 @@ class Product extends Base
32 ]; 32 ];
33 } 33 }
34 34
35 -// public function setThumbAttribute($value){  
36 -// $value['url'] = Upload::url2path($value['url']);  
37 -// $this->attributes['thumb'] = Arr::a2s($value);  
38 -// } 35 + public function setThumbAttribute($value){
  36 + $this->attributes['thumb'] = Arr::a2s($value);
  37 + }
39 38
40 public function getThumbAttribute($value){ 39 public function getThumbAttribute($value){
41 $value = Arr::s2a($value); 40 $value = Arr::s2a($value);
@@ -43,12 +42,9 @@ class Product extends Base @@ -43,12 +42,9 @@ class Product extends Base
43 return $value; 42 return $value;
44 } 43 }
45 44
46 -// public function setGalleryAttribute($value){  
47 -// foreach ($value as &$v){  
48 -// $v['url'] = Upload::url2path($v['url']);  
49 -// }  
50 -// $this->attributes['gallery'] = Arr::a2s($value);  
51 -// } 45 + public function setGalleryAttribute($value){
  46 + $this->attributes['gallery'] = Arr::a2s($value);
  47 + }
52 48
53 public function getGalleryAttribute($value){ 49 public function getGalleryAttribute($value){
54 $value = Arr::s2a($value); 50 $value = Arr::s2a($value);
@@ -65,10 +61,22 @@ class Product extends Base @@ -65,10 +61,22 @@ class Product extends Base
65 * @method :post 61 * @method :post
66 * @time :2023/7/21 11:11 62 * @time :2023/7/21 11:11
67 */ 63 */
  64 + public function setIconAttribute($value){
  65 + $this->attributes['gallery'] = Arr::a2s($value);
  66 + }
  67 +
  68 + /**
  69 + * @remark :图标获取器
  70 + * @name :getGalleryAttribute
  71 + * @author :lyh
  72 + * @method :post
  73 + * @time :2023/7/21 11:11
  74 + */
68 public function getIconAttribute($value){ 75 public function getIconAttribute($value){
69 $value = $this->getImageUrl($value); 76 $value = $this->getImageUrl($value);
70 return $value; 77 return $value;
71 } 78 }
  79 +
72 public function setAttrsAttribute($value){ 80 public function setAttrsAttribute($value){
73 $this->attributes['attrs'] = Arr::a2s($value); 81 $this->attributes['attrs'] = Arr::a2s($value);
74 } 82 }