D
D
dester332016-11-18 22:02:52
Laravel
dester33, 2016-11-18 22:02:52

Routing Laravel 5.3?

There was a question while compiling a Laravel route. For example, we use parameters to create a route:

Route::get('{name1}_prfx_{name2}/', function ($name1, $name2) {
  //
});

Actually, the question is, how do we pass $name1, $name2 here and check if they exist, then we display our template, and if not, then 404.
It is no longer clear where name1, name2 come / go.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Aksentiev, 2016-11-18
@Sanasol

What does it mean where they come from?
From the link on which the page was opened, and the link on the site page ...

R
Rustamka Vorontsov, 2016-11-19
@rmfordev

Route::get('{name1}_prfx_{name2}/', '[email protected]')->name('test');

<?php namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Test extends Controller {
    public function index(Request $request, $name1, $name2) {

        dd($name1, $name2);
    }
}

R
Roboto, 2016-11-19
@Roboto

user/name/login
name and login parameters get(post)
Route::get('user/{name}/{login}')

V
Victor, 2016-11-19
@v_decadence

Parameters come from the URL string, go to the handler function (or controller method).
If the URL doesn't match any route, Laravel will return a 404 on its own.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question