I'm doing the following in the
public function boot(DispatcherContract $events)
{
parent::boot($events);
// set Tag slug
Tag::saving(function($tag)
{
//slugify name
$tag->slug = Str::slug($tag->name);
});
}
When I run it in tinker, I get the following error:
PHP Fatal error: Class 'App\Providers\Str' not found in /var/www/questions-l5/app/Providers/EventServiceProvider.php on line 35
..but I don't know the Laravel way to import it. Do I need to just use use
, I tried to add the following to the config/app.php file:
'aliases' => [
...
'Str' => 'Illuminate\Support\Str',
.. didn't seem to make much difference though.
http://chrishayes.ca/blog/code/laravel-4-generating-unique-slugs-elegantly http://laravel.com/api/5.0/Illuminate/Support/Str.html
str_slug($title, $separator);
didn't work for you ? – Mohamed Kawsara