Hello guys, I am back with a new Laravel tutorial article and in this article, I am gonna show you how you can access a method of a controller directly in laravel 5.5. So let’s get started….
The Video tutorial is at the bottom of this article…
Note: That method will be a static function.
Read the full article to know about that.
For accessing a method of a Controller from a view page you need to give the full path of that controller in your blade like me…
<?php use App\Http\Controllers\AdminAfterAuth; $admin_dtls = AdminAfterAuth::globAdmin(); ?>
And the function of the controller must be like this.
public static function globAdmin(){ $admin_val = AdminLogin::where('id',session('admin_id'))->get(); return $admin_val; }
That’s it….
And if you are using an older version of laravel, you could get an error like this.
FatalErrorException in Container.php line 698:
Maximum function nesting level of ‘100’ reached, aborting!
To solve this error just put this code in bootstrap/autoload.php
define('LARAVEL_START', microtime(true)); ini_set('xdebug.max_nesting_level', 200);
And Now you are all set to do this……
If you have any question or any problem during to do that, don’t forget to comment here.