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

前端 未结 10 968
感情败类
感情败类 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 05:51

    For accessing a method of a Controller from a view page you need to give the full path of that controller in your blade page.

    use App\Http\Controllers\AdminAfterAuth;
    $admin_dtls = AdminAfterAuth::globAdmin();
    

    Here AdminAfterAuth is the controller class name and globAdmin is the method name.

    Now in your controller declare the method statically.

    public static function globAdmin(){
     $admin_val = AdminLogin::where('id',session('admin_id'))->get();
     return $admin_val;
     }
    

提交回复
热议问题