Automatically run and return when resolving a class?

Viewed 44

I have a service that is injected into my controller:

public function store(\App\Services\PolymorphicService $poly) {

    $poly->resolveClass();

Inside this service class I have some code that resolves POST data and returns a specific class.

For example:

resolveClass() {
     // do logic
     // return class
}

Is there a way to automatically run the method poly->resolveClass(); and have that returned on the injection part:

public function store(\App\Services\PolymorphicService $poly) {

Instead of having to manually call my method?

0 Answers
Related