@@ -73,15 +73,15 @@ public function mount(?int $modelId = null, ?string $modelClass = null): void
7373
7474 $ this ->modelClass = $ this ->modelClass ? str_replace ('\\\\' , '\\' , $ this ->modelClass ) : null ;
7575
76- if ($ this ->modelClass && !class_exists ($ this ->modelClass )) {
76+ if ($ this ->modelClass && ! class_exists ($ this ->modelClass )) {
7777 throw new \Exception (__ ('media::fields.class_not_found ' , ['class ' => $ this ->modelClass ]));
7878 }
7979
8080 if ($ this ->modelId && $ this ->modelClass ) {
8181 $ this ->model = app ($ this ->modelClass )::find ($ this ->modelId );
8282 }
8383
84- if (!$ this ->modelId || !$ this ->model ) {
84+ if (! $ this ->modelId || ! $ this ->model ) {
8585 $ this ->modelId = 0 ;
8686 }
8787 }
@@ -91,13 +91,13 @@ public function form(Form $form): Form
9191 $ upload = FileUpload::make (__ ('files ' ))
9292 ->label (__ ('media::fields.upload ' ))
9393 ->afterStateUpdated (function ($ state ) {
94- if (!$ state ) {
94+ if (! $ state ) {
9595 return ;
9696 }
9797
9898 $ processedFiles = session ('processed_files ' , []);
9999
100- if (!is_array ($ state )) {
100+ if (! is_array ($ state )) {
101101 $ fileHash = hash_file ('sha256 ' , $ state ->getRealPath ());
102102 $ fileName = $ state ->getClientOriginalName ();
103103
@@ -116,6 +116,7 @@ public function form(Form $form): Form
116116 ]))
117117 ->persistent ()
118118 ->send ();
119+
119120 return ;
120121 }
121122
@@ -172,6 +173,7 @@ public function form(Form $form): Form
172173 ]))
173174 ->persistent ()
174175 ->send ();
176+
175177 continue ;
176178 }
177179
@@ -287,7 +289,7 @@ public function toggleMediaSelection(int $mediaId)
287289 $ this ->selectedMediaIds [] = $ mediaId ;
288290 }
289291 } else {
290- if (!empty ($ this ->selectedMediaIds ) && $ this ->selectedMediaIds [0 ] === $ mediaId ) {
292+ if (! empty ($ this ->selectedMediaIds ) && $ this ->selectedMediaIds [0 ] === $ mediaId ) {
291293 $ this ->selectedMediaIds = [];
292294 } else {
293295 $ this ->selectedMediaIds = [$ mediaId ];
@@ -302,7 +304,7 @@ public function toggleMediaSelection(int $mediaId)
302304 if (isset ($ media ->uploader ->name )) {
303305 $ uploaderName = $ media ->uploader ->name ;
304306 } elseif (isset ($ media ->uploader ->first_name ) && isset ($ media ->uploader ->last_name )) {
305- $ uploaderName = $ media ->uploader ->first_name . ' ' . $ media ->uploader ->last_name ;
307+ $ uploaderName = $ media ->uploader ->first_name . ' ' . $ media ->uploader ->last_name ;
306308 }
307309 }
308310
@@ -347,7 +349,7 @@ public function applySelection()
347349 $ selectedMedia = Media::whereIn ('id ' , $ this ->selectedMediaIds )->get ();
348350
349351 if ($ selectedMedia ->isNotEmpty ()) {
350- if (!$ this ->multiple ) {
352+ if (! $ this ->multiple ) {
351353 $ media = $ selectedMedia ->first ();
352354 $ this ->dispatch ('mediaSelected ' , [
353355 'id ' => $ media ->id ,
@@ -357,7 +359,7 @@ public function applySelection()
357359 'name ' => $ media ->getAttribute ('name ' ),
358360 ]);
359361 } else {
360- $ selectedMediaData = $ selectedMedia ->map (fn ($ media ) => [
362+ $ selectedMediaData = $ selectedMedia ->map (fn ($ media ) => [
361363 'id ' => $ media ->id ,
362364 'url ' => $ media ->getUrl (),
363365 'file_name ' => $ media ->file_name ,
@@ -410,10 +412,10 @@ public function render()
410412 $ media = Media::query ()
411413 ->when ($ this ->searchQuery , function ($ query ) {
412414 $ query ->where (function ($ subQuery ) {
413- $ subQuery ->where ('file_name ' , 'like ' , '% ' . $ this ->searchQuery . '% ' )
414- ->orWhereRaw ('LOWER(JSON_EXTRACT(translations, "$.*.title")) LIKE ? ' , ['% ' . strtolower ($ this ->searchQuery ) . '% ' ])
415- ->orWhereRaw ('LOWER(JSON_EXTRACT(translations, "$.*.description")) LIKE ? ' , ['% ' . strtolower ($ this ->searchQuery ) . '% ' ])
416- ->orWhereRaw ('LOWER(JSON_EXTRACT(translations, "$.*.alt")) LIKE ? ' , ['% ' . strtolower ($ this ->searchQuery ) . '% ' ]);
415+ $ subQuery ->where ('file_name ' , 'like ' , '% ' . $ this ->searchQuery . '% ' )
416+ ->orWhereRaw ('LOWER(JSON_EXTRACT(translations, "$.*.title")) LIKE ? ' , ['% ' . strtolower ($ this ->searchQuery ). '% ' ])
417+ ->orWhereRaw ('LOWER(JSON_EXTRACT(translations, "$.*.description")) LIKE ? ' , ['% ' . strtolower ($ this ->searchQuery ). '% ' ])
418+ ->orWhereRaw ('LOWER(JSON_EXTRACT(translations, "$.*.alt")) LIKE ? ' , ['% ' . strtolower ($ this ->searchQuery ). '% ' ]);
417419 });
418420 })
419421 ->when ($ this ->fileTypeFilter , function ($ query ) {
@@ -492,25 +494,25 @@ public function render()
492494 $ uploader = $ media ->uploader ;
493495 if ($ uploader && method_exists ($ uploader , 'getName ' )) {
494496 return [
495- 'id ' => $ media ->uploader_type . ':: ' . $ media ->uploader_id ,
497+ 'id ' => $ media ->uploader_type . ':: ' . $ media ->uploader_id ,
496498 'name ' => $ uploader ->getName (),
497499 ];
498500 }
499501 if ($ uploader && isset ($ uploader ->name )) {
500502 return [
501- 'id ' => $ media ->uploader_type . ':: ' . $ media ->uploader_id ,
503+ 'id ' => $ media ->uploader_type . ':: ' . $ media ->uploader_id ,
502504 'name ' => $ uploader ->name ,
503505 ];
504506 }
505507
506508 return null ;
507509 })
508510 ->filter ()
509- ->unique (fn (array $ item ): string => $ item ['id ' ])
511+ ->unique (fn (array $ item ): string => $ item ['id ' ])
510512 ->pluck ('name ' , 'id ' )
511513 ->toArray ();
512514
513- if (!empty ($ uploaders )) {
515+ if (! empty ($ uploaders )) {
514516 $ typeName = class_basename ($ type );
515517 $ uploaderOptions [$ typeName ] = $ uploaders ;
516518 }
0 commit comments