MediaController refactor getMediaOtherInfos
This commit is contained in:
parent
8651a5cc2a
commit
c6eaf2f12b
1 changed files with 6 additions and 5 deletions
|
|
@ -34,12 +34,12 @@ use App\Models\Sujet;
|
|||
use App\Models\Tag;
|
||||
use App\Models\TypeMedia;
|
||||
use App\Traits\Http\HandlesMedia;
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
|
@ -757,15 +757,16 @@ class MediaController extends Controller
|
|||
*/
|
||||
public function getMediaOtherInfos(Media $media): JsonResponse
|
||||
{
|
||||
if (!($user = Auth::user())) {
|
||||
if (!auth()->check()) {
|
||||
abort(401, 'Cette action n\'est pas autorisée.');
|
||||
}
|
||||
|
||||
$history = Historique::whereHas('media', function ($q) use ($media) {
|
||||
$q->whereId($media->id);
|
||||
})->with('user')
|
||||
$history = Historique::query()
|
||||
->whereHas('media', fn (Builder $q) => $q->where('id', $media->id))
|
||||
->with('user')
|
||||
->orderBy('created_date', 'DESC')
|
||||
->get();
|
||||
|
||||
return \response()->json([
|
||||
'history' => $history,
|
||||
'vignettes' => $this->getVignettesByMedia($media)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue