FamilyForm   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A edit() 0 9 1
A create() 0 8 1
1
<?php
2
3
namespace App\Forms\Builders;
4
5
use App\Models\Family;
6
use App\Models\Person;
7
// use App\Models\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
        ->append('family_id', $family->id)
37
         ->value('child_id', $family->children)
0 ignored issues
show
Bug Best Practice introduced by
The property children does not exist on App\Models\Family. Since you implemented __get, consider adding a @property annotation.
Loading history...
38
         ->options('child_id', Person::all())
39
        ->edit($family);
40
    }
41
}
42