A
A
Abc Edc2015-08-23 18:11:57
Laravel
Abc Edc, 2015-08-23 18:11:57

Where to take out the logic of working with data belonging to different models?

For example, on the form, data is edited or filled in for different actions. That is, the form includes an item and data associated with it. (Existing or that will only appear after creation). And in the controller processing this form,
at least a check and a loop will be added (if the data came in an array)

MainItem
id name someColumn

RelatedItem
id mainItem_id someColumn // Как раз эти айтемы я и хочу вынести из MainItemController

if($request->SomeRelationsItems){// Могли создать только айтем без данных связанных с ним
 foreach ($request->SomeRelationsItems as $Item){ //Если их много

So, where in laravel is it better to put the logic of processing and subsequent saving of this data.
Why do I need this?
Doesn't this violate Single responsibility?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2015-08-23
@gleber1

The facade pattern is a structural design pattern that hides the complexity of a system by reducing all possible external calls to a single object that delegates them to the appropriate system objects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question