fix media

This commit is contained in:
mahdi purHosseini
2023-12-09 20:53:09 +03:30
parent 776b5257ef
commit d3d438f07e
+10 -5
View File
@@ -7,8 +7,9 @@ use Illuminate\Database\Eloquent\Model;
class MediaHelper class MediaHelper
{ {
public static function moveMediaTo($model) { public static function moveMediaTo( $model )
{
try {
request()->validate( [ request()->validate( [
'file_batch_id' => 'nullable|string' , 'file_batch_id' => 'nullable|string' ,
] ); ] );
@@ -23,7 +24,9 @@ class MediaHelper
} }
$fakeModel->delete(); $fakeModel->delete();
} }
} catch ( \Exception $exception ) {
dd( $exception );
}
} }
public static function storeMediaFor( Model $model , string $batchId = null ) public static function storeMediaFor( Model $model , string $batchId = null )
@@ -51,7 +54,8 @@ class MediaHelper
return $model->getMorphClass(); return $model->getMorphClass();
} }
public static function moveTinyMCEMediaTo($model) { public static function moveTinyMCEMediaTo( $model )
{
request()->validate( [ request()->validate( [
'tinymce_batch_id' => 'nullable|string' , 'tinymce_batch_id' => 'nullable|string' ,
@@ -70,7 +74,8 @@ class MediaHelper
} }
public static function loadMedia($model, ...$collections) { public static function loadMedia( $model , ...$collections )
{
$model->loadMissing( [ 'media' => function ( $query ) use ( $collections ) { $model->loadMissing( [ 'media' => function ( $query ) use ( $collections ) {
$query->select( '*' ); $query->select( '*' );
if ( ! empty( $collections ) ) { if ( ! empty( $collections ) ) {