我的用戶上傳存儲在storage/profile_picture/user1.png中的個人資料圖片。我使用Filesystem和Storage類來做到這一點。Laravel圖片默認
要檢索圖像我用{!! Html::image(route('profile.thumbnail', $user->profilepic_filename), "Your Picture Here", ['class'=>'img-responsive']) !!}
在我的控制器我有
public function thumbnail($filename)
{
$user = User::where('profilepicture_filename', '=', $filename)->firstOrFail();
$file = Storage::disk('local_profile')->get($user->profilepicture_filename);
//$file = URL::asset('/images/default_profilepicture.png'); //doesn't work
return (new Response($file, 200))->header('Content-Type', $mime);
}
}
我想獲得一個默認的形象,如果沒有找到資料圖片或沒有上傳。我該怎麼做?
感謝,
ķ