Answer the question
In order to leave comments, you need to log in
How to build a route in Laravel?
Good afternoon, you need to do the elementary - the route on Laravel.
There is a database (id link content), you need to register your own route for each link.
The construction below works only if site.ru/id[c DB] is accessed, but it is necessary that site.ru/link.
Route::model('link', 'Links');
Route::get('/{link}', function (Links $link) {
return $link;
});
Answer the question
In order to leave comments, you need to log in
The model must request data and by some condition
Route::get('/{link}', function ($link) {
return Links::whereLink($link)->get(); # вернет объект
});
Route::get('/{link}', function ($link) {
return $link;
});
Route::get('/{link}', function ($link) {
$data = Links::where('link', '=', $link)->get(); # вернет объект
var_dump($data); # посмотреть вывод
return $data;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question