FormStep   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A form() 0 3 1
A translations() 0 3 1
A getTranslatedTitleAttribute() 0 3 1
A translation() 0 3 1
1
<?php
2
3
namespace MedianetDev\BackpackForm\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Backpack\CRUD\app\Models\Traits\CrudTrait;
7
use Illuminate\Support\Facades\App;
8
9
class FormStep extends Model
10
{
11
    use CrudTrait;
0 ignored issues
show
introduced by
The trait Backpack\CRUD\app\Models\Traits\CrudTrait requires some properties which are not provided by MedianetDev\BackpackForm\Models\FormStep: $fakeColumns, $identifiableAttribute, $Type
Loading history...
12
13
    /*
14
    |--------------------------------------------------------------------------
15
    | GLOBAL VARIABLES
16
    |--------------------------------------------------------------------------
17
    */
18
    protected $table = 'med_form_steps';
19
    protected $guarded = ['id'];
20
21
    /*
22
    |--------------------------------------------------------------------------
23
    | FUNCTIONS
24
    |--------------------------------------------------------------------------
25
    */
26
    public function translation()
27
    {
28
        return $this->hasOne(FormStepTranslation::class)->where('locale', App::getLocale());
29
    }
30
31
    public function translations()
32
    {
33
        return $this->hasMany(FormStepTranslation::class);
34
    }
35
  
36
    public function form()
37
    {
38
    return $this->belongsTo(Formbuilder::class,'form_id');
39
    }
40
41
    /*
42
    |--------------------------------------------------------------------------
43
    | RELATIONS
44
    |--------------------------------------------------------------------------
45
    */
46
    public function getTranslatedTitleAttribute()
47
{
48
    return optional($this->translation)->title ?? $this->id;
49
}
50
51
}
52