UploadController fix Media query
This commit is contained in:
parent
665d003a5b
commit
080b400e84
1 changed files with 8 additions and 8 deletions
|
|
@ -15,6 +15,7 @@ use App\Models\Sujet;
|
|||
use App\Models\TypeMedia;
|
||||
use App\Models\User;
|
||||
use App\Traits\Http\HandlesMedia;
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
|
|
@ -97,7 +98,7 @@ class UploadController extends Controller
|
|||
// 400 instead of 422 is for resumablejs to handle properly.
|
||||
return \response()->json($e->errors(), 400);
|
||||
}
|
||||
}//end if
|
||||
} //end if
|
||||
|
||||
// We are in chunk mode, lets send the current progress.
|
||||
/** @var AbstractHandler $handler */
|
||||
|
|
@ -143,12 +144,11 @@ class UploadController extends Controller
|
|||
$this->validateUploadedFile($uplodedFile);
|
||||
|
||||
/** @var \App\Models\Media */
|
||||
$media = Media::whereId($request->media_id)
|
||||
->whereHas('sujet', function ($q) use ($sujet) {
|
||||
$q->whereId($sujet->id);
|
||||
})->whereHas('dossier', function ($q) use ($dossier) {
|
||||
$q->whereId($dossier->id);
|
||||
})->firstOrNew();
|
||||
$media = Media::query()
|
||||
->where('id', $request->input('media_id'))
|
||||
->whereHas('sujet', fn (Builder $q) => $q->where('codeSujet', $sujet->codeSujet))
|
||||
->whereHas('dossier', fn (Builder $q) => $q->where('id', $dossier->id))
|
||||
->firstOrNew();
|
||||
|
||||
// Save the file and return any response you need.
|
||||
return $this->createOrUpdateMedia($user, $uplodedFile, $media, $dossier, $sujet);
|
||||
|
|
@ -156,7 +156,7 @@ class UploadController extends Controller
|
|||
// 400 instead of 422 is for resumablejs to handle properly.
|
||||
return \response()->json($e->errors(), 400);
|
||||
}
|
||||
}//end if
|
||||
} //end if
|
||||
|
||||
// We are in chunk mode, lets send the current progress.
|
||||
/** @var AbstractHandler $handler */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue