Following this topic Use a custom function everywhere in the website I need a bit of help to finish what has been started.
So I created a folder in the app folder: Customs Then I created a helpers.php file that has the following code:
<?php
use Illuminate\Support\Str;
if (! function_exists('str_slug')) {
/**
* Generate a URL friendly "slug" from a given string.
*
* @param string $title
* @param string $separator
* @return string
*/
function my_slug($title, $separator = '-')
{
$title = str_replace('\'','_',$title);
return Str::slug($title, $separator);
}
}
I read that I now have to update my composer.json, and especially the autoload section which is basically:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
I don't understand what I should do now... psr-4 already says that the whole app folder is autoloaded, no?
I also tried to put the full path to the helpers.php but it did not work either.
What am I doing wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire