P
P
Pavel2020-06-05 21:17:22
Laravel
Pavel, 2020-06-05 21:17:22

How to pass a Request to a method?

Good evening everyone!

Tell me how to pass Request $ request to the static function

<div class="col-3">
    {{Category::menu()}}
</div>

I want to display one menu template on all the pages I need, and the salt is that Request $ request I need a day to determine the domain by which to display content (like a constructor)

there I will make the following request:
$site = Sites::where('domain', $request->getHttpHost())->first();


The controller itself:
class CategoryController extends Controller
{
    static function menu(Request $request){
        dd($request);
        return $request->all();
    }
}

and whether it will be correct to display certain blocks through aliases, or what is better invented for this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question