mercredi 30 novembre 2022

Laravel - What data should be sent from the controller to the service?

I wonder whether it is good to pass on the requestobject to a separate service after successful data validation or whether I should only pass on the data. Is there a clear statement regarding SOLID or does it not matter? My feeling is that you should only give the service what it needs.

public function store(Request $request)
{
    $someService = new SomeService;
    return $someService->create($request);
}

// or 

public function store(Request $request)
{
    $someService = new SomeService;
    return $someService->create($request->post());
}

Aucun commentaire:

Enregistrer un commentaire