Level 80
@ojwando This is what the documentation is for. I’d suggest reading it instead of asking people to write code for you.
The docs has examples of resizing images: https://image.intervention.io/v2/api/resize
Kindly show me how to resize including image intervention in this code. ''' public function store(Request $request)
{
$validatedData = $this->validate($request,[
'title'=>'required|min:3|max:150',
'tag'=>'nullable',
'body'=>'required',
'slug' => 'required|min:3|max:255|unique:posts',
'image'=> 'max:1999',
]);
$validatedData['slug'] = Str::slug($validatedData['slug'], '-');
if($request->hasFile('image')) {
// Get filename with extension
$filenameWithExt = $request->file('image')->getClientOriginalName();
// Get just filename
$filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
// Get just ext
$extension = $request->file('image')->getClientOriginalExtension();
//Filename to store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
// Upload Image
$path = $request->file('image')-> storeAs('public/images', $fileNameToStore);
} else {
$fileNameToStore = 'noimage.jpg';
}
$posts = new Post;
$posts->title = $request->input('title');
$posts->tag = $request->input('tag');
$posts->body = $request->input('body');
$str = strtolower($request->title);
$posts->image = $fileNameToStore;
$posts->slug = $validatedData['slug'];
$posts->save();
return redirect()->route('posts.index');
}
'''
Please or to participate in this conversation.