How to call a controller function inside a view in laravel 5

前端 未结 10 989
感情败类
感情败类 2020-11-29 05:23

In laravel 4 i just used a function

$varbl = App::make(\"ControllerName\")->FunctionName($params);

to call a controller function from a

10条回答
  •  孤独总比滥情好
    2020-11-29 06:10

    You can actually call a class, helper class or any declared class in your blade template but putting it in the aliases array of your app.php in the config folder

            'Helper' =>   App\Http\Helpers\Helper::class,
    

    Using the Helper as an alias, you can reference it in your blade template, example below:

            {{Helper::formatDateToAgo ($notification->created_at)}}                                                
    

提交回复
热议问题