Level 75
$fileName = Str::slug("{$request->title}.jpg");
I am trying to upload image by saving it with the post title but currently it saves like this sample post of laravel.jpg but i want it to save like this sample-post-of-laravel.jpg
here is my code below
if($request->featured_image)
{
$exploded = explode(',', $request->featured_image);
$decoded = base64_decode($exploded[1]);
$fileName = $request->title.'.'.'jpg';
$request->merge(['featured_image' => $fileName]);
Storage::disk('public')->put($fileName, $decoded);
}
$fileName = Str::slug("{$request->title}.jpg");
Please or to participate in this conversation.