美文网首页
02.laravel的route

02.laravel的route

作者: 求墨者 | 来源:发表于2019-02-18 14:56 被阅读0次

    1.配置资源路由

    对某个模型和控制器配置七个资源路由

    Route::get('issues', 'IssuesController@index')->name('issues.index');
    Route::post('issues', 'IssuesController@store')->name('issues.store');
    Route::get('issues/create', 'IssuesController@create')->name('issues.create');
    Route::get('issues/{issue}', 'IssuesController@show')->name('issues.show');
    Route::put('issues/{issue}', 'IssuesController@update')->name('issues.update');
    Route::delete('issues/{issue}', 'IssuesController@destroy')->name('issues.destroy');
    Route::get('issues/{issue}/edit', 'IssuesController@edit')->name('issues.edit');
    

    一行代码配置七个资源路由,和上面代码效果一样

    Route::resource('issues', 'IssuesController');
    

    2.普通路由的配置

    某个页面与某个控制的关联

    Route::get('about', 'WelcomeController@about');
    

    3.根路由的配置

    Route::get('/', 'WelcomeController@index');
    

    4.可选资源路由

    Route::resource('comments', 'CommentsController', ['only' => ['store']]);
    

    5.参看路由列表

    $ php artisan route:list
    

    相关文章

      网友评论

          本文标题:02.laravel的route

          本文链接:https://www.haomeiwen.com/subject/wqvaeqtx.html