getAuthIdentifier() !== (int)$post->user_id) { throw new UnauthorizedHttpException('Cette image ne vous appartient pas.'); } $first_media = $post->getFirstMedia('post_image'); if (!$first_media instanceof Media) { throw new NotFoundHttpException('Média non trouvé en base.'); } return Image::make($first_media->getPath($alias))->response($first_media->mime_type); } /** * @param string $alias * @return mixed */ public function avatar($alias = '') { /** @var User $user */ $user = User::find(Auth::user()->getAuthIdentifier()); readfile($user->getFirstMediaPath('avatars', $alias)); exit; } /** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function gallery() { $posts_with_image = Post::where('user_id', Auth::user()->getAuthIdentifier()) ->where('image', '!=', 'null') ->orderBy('created_at', 'desc') ->paginate(9); return view('gallery.my', [ 'posts' => $posts_with_image, ]); } }