FamilyForm::edit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Forms\Builders;
4
5
use App\Family;
6
use App\Person;
7
use App\Type;
8
use LaravelEnso\Forms\Services\Form;
9
10
class FamilyForm
11
{
12
    protected const TemplatePath = __DIR__.'/../Templates/families.json';
13
14
    protected Form $form;
15
16
    public function __construct()
17
    {
18
        $this->form = new Form(static::TemplatePath);
19
    }
20
21
    public function create()
22
    {
23
        return $this->form
24
    ->options('husband_id', Person::all())
25
    ->options('wife_id', Person::all())
26
    ->options('type_id', Type::all())
27
    ->options('child_id', Person::all())
28
    ->create();
29
    }
30
31
    public function edit(Family $family)
32
    {
33
        return $this->form
34
        ->options('husband_id', Person::all())
35
        ->options('wife_id', Person::all())
36
        ->options('type_id', Type::all())
37
        ->append('family_id', $family->id)
38
        ->value('child_id', $family->children)
39
        ->options('child_id', Person::all())
40
        ->edit($family);
41
    }
42
}
43