1313use Cone \Root \Support \Facades \Conversion ;
1414use Cone \Root \Traits \Filterable ;
1515use Cone \Root \Traits \InteractsWithProxy ;
16+ use Illuminate \Database \Eloquent \Attributes \Scope ;
1617use Illuminate \Database \Eloquent \Builder ;
1718use Illuminate \Database \Eloquent \Casts \Attribute ;
1819use Illuminate \Database \Eloquent \Concerns \HasUuids ;
@@ -55,15 +56,6 @@ class Medium extends Model implements Contract
5556 'properties ' => '{"conversions":[]} ' ,
5657 ];
5758
58- /**
59- * The attributes that should be cast to native types.
60- *
61- * @var array<string, string>
62- */
63- protected $ casts = [
64- 'properties ' => 'json ' ,
65- ];
66-
6759 /**
6860 * The attributes that are mass assignable.
6961 *
@@ -166,6 +158,18 @@ public static function fromPath(string $path, array $attributes = []): static
166158 ], $ attributes ));
167159 }
168160
161+ /**
162+ * Get the attributes that should be cast.
163+ *
164+ * @return array{'properties':'json'}
165+ */
166+ protected function casts (): array
167+ {
168+ return [
169+ 'properties ' => 'json ' ,
170+ ];
171+ }
172+
169173 /**
170174 * {@inheritdoc}
171175 */
@@ -313,7 +317,8 @@ public function download(?string $conversion = null): BinaryFileResponse
313317 /**
314318 * Scope the query only to the given search term.
315319 */
316- public function scopeSearch (Builder $ query , ?string $ value = null ): Builder
320+ #[Scope]
321+ protected function search (Builder $ query , string $ value ): Builder
317322 {
318323 if (is_null ($ value )) {
319324 return $ query ;
@@ -325,7 +330,8 @@ public function scopeSearch(Builder $query, ?string $value = null): Builder
325330 /**
326331 * Scope the query only to the given type.
327332 */
328- public function scopeType (Builder $ query , string $ value ): Builder
333+ #[Scope]
334+ protected function type (Builder $ query , string $ value ): Builder
329335 {
330336 return match ($ value ) {
331337 'image ' => $ query ->where ($ query ->qualifyColumn ('mime_type ' ), 'like ' , 'image% ' ),
0 commit comments