Answer the question
In order to leave comments, you need to log in
What is the best way to send a 404 to the user if the url before the category is incorrect?
Hello, I have the following route:
Route::get('/katalog/{alias}', 'Web\[email protected]')->where('alias','(.*)?');
public function catalogItems($alias)
{
$arrayUrl = explode("/",$alias);
$entity = Category::GetByAlias(Arr::last($arrayUrl))->first();
return view("web.page.entity.entity",[
"entity" => $entity,
"children" => $entity->children()->Active()->get(),
"products" => $entity->products()->Active()->with("images")->get(),
"breadcrumbs" => Breadcrumbs::make($entity)
]);
}
домен/katalog/catalog1/catalog1-1
домен/katalog/qweqweqweqweqweqwe/catalog1-1
домен/katalog/qweqweqweqweqweqwe/catalog1-1
return 404 to such a url, I think to do this by checking the current url with an array of ancestor aliases, this array returns the class Breadcrumbs::make($entity) and if there is a difference, then return 404. Please tell me if it is correct to do so? Maybe you can do it differently. Thank you in advance for your response.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question