@@ -73,15 +73,15 @@ public function mount(?int $modelId = null, ?string $modelClass = null): void
73
73
74
74
$ this ->modelClass = $ this ->modelClass ? str_replace ('\\\\' , '\\' , $ this ->modelClass ) : null ;
75
75
76
- if ($ this ->modelClass && !class_exists ($ this ->modelClass )) {
76
+ if ($ this ->modelClass && ! class_exists ($ this ->modelClass )) {
77
77
throw new \Exception (__ ('media::fields.class_not_found ' , ['class ' => $ this ->modelClass ]));
78
78
}
79
79
80
80
if ($ this ->modelId && $ this ->modelClass ) {
81
81
$ this ->model = app ($ this ->modelClass )::find ($ this ->modelId );
82
82
}
83
83
84
- if (!$ this ->modelId || !$ this ->model ) {
84
+ if (! $ this ->modelId || ! $ this ->model ) {
85
85
$ this ->modelId = 0 ;
86
86
}
87
87
}
@@ -91,13 +91,13 @@ public function form(Form $form): Form
91
91
$ upload = FileUpload::make (__ ('files ' ))
92
92
->label (__ ('media::fields.upload ' ))
93
93
->afterStateUpdated (function ($ state ) {
94
- if (!$ state ) {
94
+ if (! $ state ) {
95
95
return ;
96
96
}
97
97
98
98
$ processedFiles = session ('processed_files ' , []);
99
99
100
- if (!is_array ($ state )) {
100
+ if (! is_array ($ state )) {
101
101
$ fileHash = hash_file ('sha256 ' , $ state ->getRealPath ());
102
102
$ fileName = $ state ->getClientOriginalName ();
103
103
@@ -116,6 +116,7 @@ public function form(Form $form): Form
116
116
]))
117
117
->persistent ()
118
118
->send ();
119
+
119
120
return ;
120
121
}
121
122
@@ -172,6 +173,7 @@ public function form(Form $form): Form
172
173
]))
173
174
->persistent ()
174
175
->send ();
176
+
175
177
continue ;
176
178
}
177
179
@@ -287,7 +289,7 @@ public function toggleMediaSelection(int $mediaId)
287
289
$ this ->selectedMediaIds [] = $ mediaId ;
288
290
}
289
291
} else {
290
- if (!empty ($ this ->selectedMediaIds ) && $ this ->selectedMediaIds [0 ] === $ mediaId ) {
292
+ if (! empty ($ this ->selectedMediaIds ) && $ this ->selectedMediaIds [0 ] === $ mediaId ) {
291
293
$ this ->selectedMediaIds = [];
292
294
} else {
293
295
$ this ->selectedMediaIds = [$ mediaId ];
@@ -302,7 +304,7 @@ public function toggleMediaSelection(int $mediaId)
302
304
if (isset ($ media ->uploader ->name )) {
303
305
$ uploaderName = $ media ->uploader ->name ;
304
306
} 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 ;
306
308
}
307
309
}
308
310
@@ -347,7 +349,7 @@ public function applySelection()
347
349
$ selectedMedia = Media::whereIn ('id ' , $ this ->selectedMediaIds )->get ();
348
350
349
351
if ($ selectedMedia ->isNotEmpty ()) {
350
- if (!$ this ->multiple ) {
352
+ if (! $ this ->multiple ) {
351
353
$ media = $ selectedMedia ->first ();
352
354
$ this ->dispatch ('mediaSelected ' , [
353
355
'id ' => $ media ->id ,
@@ -357,7 +359,7 @@ public function applySelection()
357
359
'name ' => $ media ->getAttribute ('name ' ),
358
360
]);
359
361
} else {
360
- $ selectedMediaData = $ selectedMedia ->map (fn ($ media ) => [
362
+ $ selectedMediaData = $ selectedMedia ->map (fn ($ media ) => [
361
363
'id ' => $ media ->id ,
362
364
'url ' => $ media ->getUrl (),
363
365
'file_name ' => $ media ->file_name ,
@@ -410,10 +412,10 @@ public function render()
410
412
$ media = Media::query ()
411
413
->when ($ this ->searchQuery , function ($ query ) {
412
414
$ 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 ). '% ' ]);
417
419
});
418
420
})
419
421
->when ($ this ->fileTypeFilter , function ($ query ) {
@@ -492,25 +494,25 @@ public function render()
492
494
$ uploader = $ media ->uploader ;
493
495
if ($ uploader && method_exists ($ uploader , 'getName ' )) {
494
496
return [
495
- 'id ' => $ media ->uploader_type . ':: ' . $ media ->uploader_id ,
497
+ 'id ' => $ media ->uploader_type . ':: ' . $ media ->uploader_id ,
496
498
'name ' => $ uploader ->getName (),
497
499
];
498
500
}
499
501
if ($ uploader && isset ($ uploader ->name )) {
500
502
return [
501
- 'id ' => $ media ->uploader_type . ':: ' . $ media ->uploader_id ,
503
+ 'id ' => $ media ->uploader_type . ':: ' . $ media ->uploader_id ,
502
504
'name ' => $ uploader ->name ,
503
505
];
504
506
}
505
507
506
508
return null ;
507
509
})
508
510
->filter ()
509
- ->unique (fn (array $ item ): string => $ item ['id ' ])
511
+ ->unique (fn (array $ item ): string => $ item ['id ' ])
510
512
->pluck ('name ' , 'id ' )
511
513
->toArray ();
512
514
513
- if (!empty ($ uploaders )) {
515
+ if (! empty ($ uploaders )) {
514
516
$ typeName = class_basename ($ type );
515
517
$ uploaderOptions [$ typeName ] = $ uploaders ;
516
518
}
0 commit comments