Traits and Dependency Injection

Posted 3 years ago by domioanna

So, because I've got several Controllers that use the same methods and each of those methods are more or less exact other than a couple of variables on each Controller, I've created a trait and set up getters and setters for each of these variables which are called and set in the __construct() of each Controller.

Now, my question... How do I set the 'Request $request' dependency injection on a method? Each Controller will need it's own request calling but I cannot work out how inject it...

public function store(Request $request)
{
    // Do something amazing...
}

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.