Today, I needed to turn my title of the gallery I was making into url slug. So I searched the internet and came across this beautiful function that does so.

Str::slug('parameters');

So how to do this?
First get the data. Then add a gallery slug into that data using the above function. For example

$data = request()->all();
$data['gallery_slug'] = Str::slug($data['gallery_name']);

Don’t forget to declare str before use.

use Illuminate\Support\Str;

I hope this helps you.