Answer the question
In order to leave comments, you need to log in
How to pass template names through laravel route?
Route::get('equipment', '[email protected]');
Route::get('/', '[email protected]');
public function allitems(){
return view('здесь нужно передать название шаблона',
[
'all' => $this->eqs(),
'types' => $this->types()
]);
}
Answer the question
In order to leave comments, you need to log in
Route::get('/', '[email protected]');
Route::get('equipment', '[email protected]');
private function allItemsInternal(string $template){
return view($template, [
'all' => $this->eqs(),
'types' => $this->types()
]);
}
public function allItems(){
return $this->allItemsInternal('all');
}
public function allEquipmentItems(){
return $this->allItemsInternal('equipment');
}
in the controller find out the route Route::currentRouteName();
and knowing the route, choose a template
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question