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

Laravel's resource route point syntax tips

藏色散人
Release: 2020-03-11 08:57:58
forward
2909 people have browsed it

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']]);
Copy after login

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;
    }
}
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template