若Route中有Route::get('home/test', 'HomeController@index')->name('test');
①視圖中的href跳轉
一、<a href="{{ url('home/test') }}">
區別:最方便,但路由改變時就又要修改了
二、<a href="{{ route('test') }}">
區別:可直接命名使用,不因uri改變而改變,我喜歡用
注:用route需要在route中->name()
三、<a href="{{ action('HomeController@index') }}">
區別:直接指定相關控制器,受影響最小
四、<a href="絕對路徑">
區別:最容易受影響,不推薦使用
②控制器中redirect跳轉使用
一、return redirect('home/test'); <=> return redirect()->to('home/test');
區別:同①一
二、return redirect()->action('HomeController@index');
區別:同①三
三、return redirect()->route(test'');
區別:同①二
四、return redirect()->back(); <=> return back();
說明:返回上一頁面
③各個資源路徑常量
一、public_path('uploads');
說明:public文件路徑
二、base_path('xx');
三、app_path('xx');
四、resource_path('xx');