Есть такой контроллер, подскажите пожалуйста как можно сделать его почище ?
class PageController extends Controller
{
public function catalog($alias)
{
$arrayUrl = explode("/",$alias);
$entity = Category::GetByAlias(Arr::last($arrayUrl))->firstOrFail();
return view("web.page.entity.entity",[
"entity" => $entity,
"children" => $entity->children()->SelectMini()->Active()->get(),
"products" => $entity->products()->Active()->SortImages()->get(),
"breadcrumbs" => (new Breadcrumbs)->make($entity)
->prepend(["name" => "Каталог","url" => route("catalogs")],true)
->get()
]);
}
public function services($alias)
{
$arrayUrl = explode("/",$alias);
$entity = Service::GetByAlias(Arr::last($arrayUrl))->firstOrFail();
return view("web.page.entity.entity",[
"entity" => $entity,
"children" => $entity->children()->SelectMini()->Active()->get(),
"products" => $entity->products()->Active()->SortImages()->get(),
"breadcrumbs" => (new Breadcrumbs)->make($entity)
->prepend(["name" => "Услуги","url" => route("services")],true)
->get()
]);
}
public function product($alias, $id)
{
$product = Product::with("sizes","colors","country","materials")->SortImages()->findOrFail($id);
return view("web.page.product.product",[
"product" => $product,
"breadcrumbs" => (new Breadcrumbs)->make($product)
->prepend(["name" => "Каталог","url" => route("catalogs")],true)
->get()
]);
}
}