امروز:پنج شنبه ,۱۳۹۸/۰۳/۳۰
Download http://bigtheme.net/joomla Free Templates Joomla! 3
Home / Laravel / get curent action name and controller name in laravel

get curent action name and controller name in laravel

get curent action name and controller name inlaravel

first call namespace


        use Illuminate\Support\Facades\Route;
$curentaction = Route::getCurrentRoute()->getAction();


                echo "<pre>";
                print_r($curentaction);
                echo "</pre>";

output

Array
(
    [middleware] => Array
        (
            [۰] => web
            [۱] => auth
        )

    [uses] => App\Http\Controllers\ProfileController@getpaymentsettings
    [controller] => App\Http\Controllers\ProfileController@getpaymentsettings
    [namespace] => App\Http\Controllers
    [prefix] => /profile
    [where] => Array
        (
        )

)

actionname only



                $curentaction2 = Route::getCurrentRoute()->getActionMethod();

                echo "<pre>";
                print_r($curentaction2);
                echo "</pre>";

output

index
    $currentAction = \Route::currentRouteAction();

                echo "<pre>";
                print_r($currentAction);
                echo "</pre>";

output

App\Http\Controllers\ProfileController@getpaymentsettings
                list($controller, $method) = explode('@', $currentAction);
                $controller = preg_replace('/.*\\\/', '', $controller);
                echo "<pre>";
                print_r($controller);
                echo "</pre>";

output

ProfileController

Check Also

نکته-مهم-session-laravel

نکته-مهم-session-laravel کار با سشن در فریم ورک لاراول ساده است که به چند روش قابل …

پاسخ دهید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *