1 | <?php |
||
45 | class Category extends Model |
||
46 | { |
||
47 | use HasSlug; |
||
48 | use NodeTrait; |
||
49 | use SoftDeletes; |
||
50 | use HasTranslations; |
||
51 | use ValidatingTrait; |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | protected $fillable = [ |
||
57 | 'slug', |
||
58 | 'name', |
||
59 | 'description', |
||
60 | NestedSet::LFT, |
||
61 | NestedSet::RGT, |
||
62 | NestedSet::PARENT_ID, |
||
63 | ]; |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | protected $casts = [ |
||
69 | 'slug' => 'string', |
||
70 | NestedSet::LFT => 'integer', |
||
71 | NestedSet::RGT => 'integer', |
||
72 | NestedSet::PARENT_ID => 'integer', |
||
73 | 'deleted_at' => 'datetime', |
||
74 | ]; |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | protected $observables = [ |
||
80 | 'validating', |
||
81 | 'validated', |
||
82 | ]; |
||
83 | |||
84 | /** |
||
85 | * The attributes that are translatable. |
||
86 | * |
||
87 | * @var array |
||
88 | */ |
||
89 | public $translatable = [ |
||
90 | 'name', |
||
91 | 'description', |
||
92 | ]; |
||
93 | |||
94 | /** |
||
95 | * The default rules that the model will validate against. |
||
96 | * |
||
97 | * @var array |
||
98 | */ |
||
99 | protected $rules = []; |
||
100 | |||
101 | /** |
||
102 | * Whether the model should throw a |
||
103 | * ValidationException if it fails validation. |
||
104 | * |
||
105 | * @var bool |
||
106 | */ |
||
107 | protected $throwValidationExceptions = true; |
||
108 | |||
109 | /** |
||
110 | * Create a new Eloquent model instance. |
||
111 | * |
||
112 | * @param array $attributes |
||
113 | */ |
||
114 | public function __construct(array $attributes = []) |
||
128 | |||
129 | /** |
||
130 | * Get all attached models of the given class to the category. |
||
131 | * |
||
132 | * @param string $class |
||
133 | * |
||
134 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
135 | */ |
||
136 | public function entries(string $class): MorphToMany |
||
140 | |||
141 | /** |
||
142 | * Get the options for generating the slug. |
||
143 | * |
||
144 | * @return \Spatie\Sluggable\SlugOptions |
||
145 | */ |
||
146 | public function getSlugOptions(): SlugOptions |
||
153 | } |
||
154 |