Update   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 2
1
<?php
2
3
namespace App\Http\Controllers\Families;
4
5
use App\Http\Requests\ValidateFamilyRequest;
6
use App\Models\Family;
7
use App\Models\Person;
8
use Illuminate\Routing\Controller;
9
10
class Update extends Controller
11
{
12
    public function __invoke(ValidateFamilyRequest $request, $family)
13
    {
14
        $family = Family::find($family);
15
16
        if ($family) {
17
            $family->update($request->validated());
18
            $family->children()->update(['child_in_family_id' => null]);
19
            $family->children()->saveMany(Person::whereIn('id', $request->get('child_id', []))->get());
20
        }
21
        //return with 404
22
23
        return ['message' => __('The family was successfully updated')];
24
    }
25
}
26