您的位置 首页 php

Laravel之Resource Route的点语法小技巧

Laravel的Resource Route中隐藏着一个小技巧,就是.在url中的使用,如:

Route::resource('clients.accounts', 'AccountController', ['only' => ['index', 'show']]);

其对应的url是/clients/{client_id}/accounts/{account_id}和/clients/{client_id}/accounts/,这个技巧很有用。

推荐:laravel教程

控制器源码是:

namespace App\Http\Controllers;class AccountController extends Controller{    public function index($client_id)    {        return $client_id;    }    public function show($client_id, $account_id)    {        return $client_id . '/' . $account_id;    }}

相关推荐:

PHP视频教程:https://www.php.cn/course/list/29/type/2.html

文章来源:智云一二三科技

文章标题:Laravel之Resource Route的点语法小技巧

文章地址:https://www.zhihuclub.com/28097.shtml

关于作者: 智云科技

热门文章

网站地图