动态(数据库值)管理员前缀url laravel 5.4

时间:2018-01-05 18:17:23

标签: laravel laravel-5.4 dynamic-url

Hi i m laravel fresher so i don't know How to set backend url dynamic

像  的 https://sample.com/admin    至  的 https://sample.com/somename

Route::group(['prefix' =>'admin','middleware' => 'Admin_kernal'], function ()

{ //code here } Thanking you.....

2 个答案:

答案 0 :(得分:1)

了解route parameters。设置路线:

Route::get('{name}', 'SomeController@handle');

handle()方法SomeController

public function handle($name) {
    echo $name;
    ....
}

答案 1 :(得分:0)

您也可以像这样设置路线 -

Route::get('{name?}', 'SomeController@showView');

并使方法如 -

public function showFrontEndView($name=null)
{
    if(View::exists($name))
    {
        return view($name);
    }
    else
    {
        return view('404');
    }
}

您应该阅读routing laravel-5.4

你也可以在laravel 5.5中阅读resource controller laravel的新风味