There is a little trick hidden in Laravel's Resource Route, which is the use of . in the url, such as:
Route::resource('clients.accounts', 'AccountController', ['only' => ['index', 'show']]);
The corresponding url is /clients /{client_id}/accounts/{account_id} and /clients/{client_id}/accounts/
, this trick is very useful.
Recommended: laravel tutorial
The controller source code is:
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; } }
Related recommendations:
PHP video tutorial: https://www.php.cn/course/list/29/type/2.html
The above is the detailed content of Laravel's resource route point syntax tips. For more information, please follow other related articles on the PHP Chinese website!