| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace FluentCart\App\Models; |
| 4 | 4 | use FluentCart\Framework\Support\Arr; |
| 5 | 5 | use FluentCart\App\Models\Concerns\CanSearch; |
| 6 | +use FluentCart\App\Models\Concerns\CanUpdateBatch; | |
| 6 | 7 | |
| 7 | 8 | /** |
| 8 | 9 | * Attributes Group Model - DB Model for Attributes Group eg: color, size etc |
| 9 | 10 | * |
| @@ -14,9 +15,9 @@ | ||
| 14 | 15 | * @version 1.0.0 |
| 15 | 16 | */ |
| 16 | 17 | class AttributeGroup extends Model |
| 17 | 18 | { |
| 18 | - use CanSearch; | |
| 19 | + use CanSearch, CanUpdateBatch; | |
| 19 | 20 | |
| 20 | 21 | public static function boot() |
| 21 | 22 | { |
| 22 | 23 | parent::boot(); |
| @@ -31,10 +32,19 @@ | ||
| 31 | 32 | 'title', |
| 32 | 33 | 'slug', |
| 33 | 34 | 'description', |
| 34 | 35 | 'settings', |
| 36 | + 'serial', | |
| 37 | + // is_system intentionally NOT fillable — it's a trust flag that only the | |
| 38 | + // seeder sets (via bulk insert, which bypasses fillable). Keeping it out | |
| 39 | + // of mass-assignment means user-created groups stay is_system=0 even if | |
| 40 | + // a client sneaks the field into a request body. | |
| 35 | 41 | ]; |
| 36 | 42 | |
| 43 | + protected $casts = [ | |
| 44 | + 'is_system' => 'boolean', | |
| 45 | + ]; | |
| 46 | + | |
| 37 | 47 | public function setSettingsAttribute($value) |
| 38 | 48 | { |
| 39 | 49 | if (is_array($value)) { |
| 40 | 50 | $value = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
| @@ -56,9 +66,9 @@ | ||
| 56 | 66 | |
| 57 | 67 | /** |
| 58 | 68 | * hasMany: Group has many Terms |
| 59 | 69 | * |
| 60 | - * @return \FluentCart\Framework\Database\Orm\Relations\hasMany | |
| 70 | + * @return \FluentCart\Framework\Database\Orm\Relations\HasMany | |
| 61 | 71 | */ |
| 62 | 72 | public function terms() |
| 63 | 73 | { |
| 64 | 74 | return $this->hasMany(AttributeTerm::class, 'group_id', 'id'); |