Home >PHP Framework >Laravel >Laravel's resource route point syntax tips

Laravel's resource route point syntax tips

藏色散人
藏色散人forward
2020-03-11 08:57:582915browse

Laravel's resource route point syntax tips

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!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete