how function call another function using this "->" for example "Route::get()->name()"or "Route::get()->where()"
CodePudding user response:
In Laravel you can set routes using this code, if you set a route and you want to name it you can add the ->name()
method after your declaration.
One example:
Route::get('/', 'HomeController@index')->name('LandingPage');
landing page
is the name of the route /
.
CodePudding user response:
Checkout Pipeline in laravel that might answer your question or here is a quick video on it
CodePudding user response:
Your question has two questions itself.
Lets look into Route::get('/url', 'ControllerName@functionName)->name('route.name');
url
is what you wish to display in the browser url.
ControllerName
is the name of your controller where your function exist.
functionName
is the name of your function that you wish your url for that functional behavior.
route.name
would be the name for your easy access of the function through out your project where you would like to process as reference. Eg: if you call route('route.name')
it would mean that your logic has to access this function and process accordingly to your logic within the function.
Example:
This way your action will end up at route('route.name')
to what ever was in that function.
public function index() {
// some logic ....
return redirect()->route('route.name');
}
Now, lets look into
Route::get('/url/{id}', 'ControllerName@functionName)->where('id', '[0-9] ');
Here, all the keywords are same as above example except it has a where clause. What the where clause does is that, it makes sure that the {id}
passed in the url needs to be within the '[0-9] '
parameters. Please look into the documentation for more details.
https://laravel.com/docs/5.0/routing#route-parameters[enter link description here]1