Level 70
Use 3 ` before and after of your code to make your code more readable.
BTW, what is the issue in your code?
public function store(Request $request) { $this->validate($request,[ 'title' =>'required', 'image' => 'mimes:jpeg,jpg,bmp,png'
]);
$image = $request->file('image');
$slug = str_slug($request->title);
if (isset($image))
{
$currentDate = Carbon::now()->toDateString();
$imagename = $slug.'-'.$currentDate.'-'. uniqid() .'.'. $image->getClientOriginalExtension();
$image_resize = Image::make($image->getRealPath());
$image_resize->resize(1600,1066);
if (!file_exists('storage/uploads/post'))
{
mkdir('storage/uploads/post',0777,true);
}
$image_resize->save('storage/uploads/post/'.$imagename);
}else{
$imagename = "default.png";
}
$post = new Post();
$post->title = $request->title;
$post->slug = str_slug($request->title);
$post->image = $imagename;
$post->save();
Toastr::success('Post Successfully Save:)','Success');
return redirect()->route('admin.post.index');
}
Please or to participate in this conversation.