2 years ago

Refactoring messy store method - need help understanding use cases from tutorial lesson 2

Posted 2 years ago by longestdrive

Hi I'm upgrading an app from 4.2 to 5,5 and whilst doing this refactoring a lot of the app. I've followed the tutorial whip monstrous code and trying to implement the approaches in lesson 2 (use cases) and lesson 7 (tasks) but I'm having trouble implementing the approaches due to my lack of understanding of some basics...

Tried to ask a question on another forum but got frankly no help and a steer away from laravel so hoping for some humane responses here...


In using lesson 2 - use cases I've tried implementing this code:

abstract class BaseBookingHandler

public static function perform(Request $request)
    return (new static(

abstract public function handle(Request $request);


Then in my work class I have:

class BookClubEvent extends BaseBookingHandler
public function handle(Request $request)
        //do stuff

All - ok and following the tutorial. But then my work class needs dependencies - I've tried injecting them in the work class but then get php errors around not passing them correctly ie not passing any.

So some questions:

Where should I inject my dependencies? In the parent class and then if there how do I initiate the classes correctly or in the child work class and then call parent::__contstruct?

Very confused with late static binding and how to intiate correctly

Secondly - looking at tasks (lesson 8) using an array of classes and working through them - how do I hand off variables to each class to work through the tasks in hand and secondly what if these classes need dependencies such as repositories - where and how do I inject them then


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