1 | <?php |
||
16 | abstract class Ticketable extends Model |
||
17 | { |
||
18 | use HasSlug; |
||
19 | use TicketableTrait; |
||
20 | use HasTranslations; |
||
21 | use ValidatingTrait; |
||
22 | use CacheableEloquent; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | protected $fillable = [ |
||
28 | 'slug', |
||
29 | 'name', |
||
30 | 'description', |
||
31 | 'is_public', |
||
32 | 'starts_at', |
||
33 | 'ends_at', |
||
34 | 'timezone', |
||
35 | 'location', |
||
36 | ]; |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | protected $casts = [ |
||
42 | 'slug' => 'string', |
||
43 | 'name' => 'string', |
||
44 | 'description' => 'string', |
||
45 | 'is_public' => 'boolean', |
||
46 | 'starts_at' => 'datetime', |
||
47 | 'ends_at' => 'datetime', |
||
48 | 'timezone' => 'string', |
||
49 | 'location' => 'string', |
||
50 | 'deleted_at' => 'datetime', |
||
51 | ]; |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | protected $observables = [ |
||
57 | 'validating', |
||
58 | 'validated', |
||
59 | ]; |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | public $translatable = [ |
||
65 | 'name', |
||
66 | 'description', |
||
67 | ]; |
||
68 | |||
69 | /** |
||
70 | * The default rules that the model will validate against. |
||
71 | * |
||
72 | * @var array |
||
73 | */ |
||
74 | protected $rules = [ |
||
75 | 'slug' => 'required|alpha_dash|max:150', |
||
76 | 'name' => 'required|string|max:150', |
||
77 | 'description' => 'nullable|string|max:10000', |
||
78 | 'is_public' => 'sometimes|boolean', |
||
79 | 'starts_at' => 'required|string', |
||
80 | 'ends_at' => 'required|string', |
||
81 | 'timezone' => 'required|string|timezone', |
||
82 | 'location' => 'nullable|string', |
||
83 | ]; |
||
84 | |||
85 | /** |
||
86 | * Whether the model should throw a |
||
87 | * ValidationException if it fails validation. |
||
88 | * |
||
89 | * @var bool |
||
90 | */ |
||
91 | protected $throwValidationExceptions = true; |
||
92 | |||
93 | /** |
||
94 | * Get the public resources. |
||
95 | * |
||
96 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
97 | * |
||
98 | * @return \Illuminate\Database\Eloquent\Builder |
||
99 | */ |
||
100 | public function scopePublic(Builder $builder): Builder |
||
104 | |||
105 | /** |
||
106 | * Get the private resources. |
||
107 | * |
||
108 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
109 | * |
||
110 | * @return \Illuminate\Database\Eloquent\Builder |
||
111 | */ |
||
112 | public function scopePrivate(Builder $builder): Builder |
||
116 | |||
117 | /** |
||
118 | * Get the options for generating the slug. |
||
119 | * |
||
120 | * @return \Spatie\Sluggable\SlugOptions |
||
121 | */ |
||
122 | public function getSlugOptions(): SlugOptions |
||
129 | |||
130 | /** |
||
131 | * Activate the resource. |
||
132 | * |
||
133 | * @return $this |
||
134 | */ |
||
135 | public function makePublic() |
||
141 | |||
142 | /** |
||
143 | * Deactivate the resource. |
||
144 | * |
||
145 | * @return $this |
||
146 | */ |
||
147 | public function makePrivate() |
||
153 | } |
||
154 |