Hi my app was running preety well until today i realise image link is broken why working with notification and hoping to deploy anytime soon and a nighmare emerge. Here is how i set up my image algorithm. Am using intervention image package. As i said everything was working perfectly fine as first and i will be grateful if anyone can help with this nightmare.
This my store method
public function store(Request $request)
{
$this->validate($request,[
'title' => 'required',
'image' => 'required',
'categories' => 'required',
'body' => 'required',
]);
$image = $request->file('image');
$slug = str_slug($request->title);
if(isset($image))
{
# make unipue name for image
$currentDate = Carbon::now()->toDateString();
$imageName = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();
if(!Storage::disk('public')->exists('post'))
{
Storage::disk('public')->makeDirectory('post');
}
$postImage = Image::make($image)->resize(1600,1066)->stream();
Storage::disk('public')->put('post/'.$imageName,$postImage);
} else {
$imageName = "purple.png";
}
$post = new Post();
$post->user_id = Auth::id();
$post->title = $request->title;
$post->slug = $slug;
$post->image = $imageName;
$post->body = $request->body;
$post->save();
return redirect()->route('admin.post.index');
}
This my view and this how the image is called
{{ asset('Storage/post/'.$post->image) }}
php artisan storage:link have been utilized
this how my filesystem is set up
'default' => env('FILESYSTEM_DRIVER', 'local'),
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
If am missing anything please let me know thanks in advance.