I have many helper classes in my app/Helpers
directory.
Let use DateHelper.php
as example.
]1
Then, I have HelperServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class HelperServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
foreach (glob(app_path().'/Helpers/*.php') as $filename){
require_once($filename);
}
}
}
Then, I register it in my 'providers' array in config/app.php
'App\Providers\HelperServiceProvider',
Then, I create an alias
'DateHelper' => App\Helpers\DateHelper::class,
Then, I tried to call it
{{ DateHelper::f1($visitor->created_at) }}
Then, I run composer dumpauto
I kept getting
FatalErrorException in 7a9854b6de232272901da9bc64800d54 line 38:
Class 'DateHelper' not found
Can someone please tell me what did I do wrong ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire