kphcdr 1 ano atrás
pai
commit
7cf0ccb4ed

+ 2 - 1
app/Models/Goods/Spec.php

@@ -53,10 +53,11 @@ class Spec extends BaseModel
         $return = [
             "id" => $this->id,
             "name" => $this->name,
-            "is_custom" => $this->is_custom,
+            "is_custom" => (bool)$this->is_custom,
             "index_weight" => $this->index_weight,
             "category_weight" => $this->category_weight,
             "search_weight" => $this->search_weight,
+            "created_at" => $this->created_at->format("Y-m-d"),
         ];
 
         if (in_array(self::FORMAT_ATTR, $options)) {

+ 2 - 2
app/Modules/Admin/Services/GoodsService.php

@@ -15,7 +15,7 @@ class GoodsService extends BaseService
     public function specPaginate($params)
     {
         $p = Spec::query()->when($params['name'], function (Builder $query) use ($params) {
-            return $query->where("name", $params['name']);
+            return $query->where("name", 'like', "%{$params['name']}%");
         })->orderByDesc("id")->paginate($params['page_size']);
 
         return [
@@ -39,7 +39,7 @@ class GoodsService extends BaseService
         $spec->index_weight = Arr::get($params, 'index_weight');
         $spec->category_weight = Arr::get($params, 'category_weight');
         $spec->search_weight = Arr::get($params, 'search_weight');
-        $spec->is_custom = Arr::get($params, 'is_custom');
+        $spec->is_custom = (int)Arr::get($params, 'is_custom');
 
         DB::transaction(function () use ($params, $spec) {
             $spec->save();