| @@ 7-27 (lines=21) @@ | ||
| 4 | ||
| 5 | use Illuminate\Http\Request; |
|
| 6 | ||
| 7 | trait CreateTrait |
|
| 8 | { |
|
| 9 | protected $optionsToArrayStore; |
|
| 10 | ||
| 11 | public function store(Request $request) |
|
| 12 | { |
|
| 13 | $entity = $this->mainService |
|
| 14 | ->store( |
|
| 15 | $this->filterRequest( |
|
| 16 | $request->json()->all(), |
|
| 17 | $this->mainService |
|
| 18 | ->getMainRepository() |
|
| 19 | ->createEntity() |
|
| 20 | ->getOnlyStore() |
|
| 21 | ) |
|
| 22 | ) |
|
| 23 | ->flush(); |
|
| 24 | ||
| 25 | return response()->json($entity->toArray($this->optionsToArrayStore)); |
|
| 26 | } |
|
| 27 | } |
|
| 28 | ||
| @@ 7-28 (lines=22) @@ | ||
| 4 | ||
| 5 | use Illuminate\Http\Request; |
|
| 6 | ||
| 7 | trait UpdateTrait |
|
| 8 | { |
|
| 9 | protected $optionsToArrayUpdate; |
|
| 10 | ||
| 11 | public function update(Request $request, $id) |
|
| 12 | { |
|
| 13 | $entity = $this->mainService |
|
| 14 | ->update( |
|
| 15 | $id, |
|
| 16 | $this->filterRequest( |
|
| 17 | $request->json()->all(), |
|
| 18 | $this->mainService |
|
| 19 | ->getMainRepository() |
|
| 20 | ->createEntity() |
|
| 21 | ->getOnlyUpdate() |
|
| 22 | ) |
|
| 23 | ) |
|
| 24 | ->flush(); |
|
| 25 | ||
| 26 | return response()->json($entity->toArray($this->optionsToArrayUpdate)); |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||