E
E
Eugene-Kei2020-07-23 12:44:32
Laravel
Eugene-Kei, 2020-07-23 12:44:32

Laravel IoC how to make a completed model passed to a dependency?

Hello!
There are classes Company, CompanyFilter and RequestFilter

Company - model Illuminate\Database\Eloquent\Model

CompanyFilter has the following constructor

public function __construct(RequestFilter $requestFilter, Company $company)
    {
        parent::__construct($requestFilter, $company);
    }


in RequestFilter
public function __construct(Request $request)
    {
        $this->request = $request;
    }


I want only CompanyFilter to be passed to the controller method
public function show(CompanyFilter $companyFilter)
    {
        //...
    }

At the same time, the Company model is entered in the CompanyFilter dependency, but it is empty.
If I do this, then the Company model comes already filled
public function show(Request $request, Company $company)
    {
       //...
    }

Maybe it needs to be configured somewhere? While vaguely imagine how IoC works.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2020-07-23
@Nc_Soft

https://laravel.com/docs/7.x/routing#route-model-b...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question