FormbuilderTranslation::formbuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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 Spatie\Activitylog\LogOptions;
8
use Spatie\Activitylog\Traits\LogsActivity;
9
10
class FormbuilderTranslation extends Model
11
{
12
    use CrudTrait, LogsActivity;
0 ignored issues
show
introduced by
The trait Backpack\CRUD\app\Models\Traits\CrudTrait requires some properties which are not provided by MedianetDev\BackpackForm...\FormbuilderTranslation: $fakeColumns, $identifiableAttribute, $Type
Loading history...
introduced by
The trait Spatie\Activitylog\Traits\LogsActivity requires some properties which are not provided by MedianetDev\BackpackForm...\FormbuilderTranslation: $submitEmptyLogs, $logExceptAttributes, $attributeRawValues, $logName, $dontLogIfAttributesChangedOnly, $descriptionForEvent, $logOnlyDirty, $logFillable, $logUnguarded, $logAttributes
Loading history...
13
14
    /*
15
    |--------------------------------------------------------------------------
16
    | GLOBAL VARIABLES
17
    |--------------------------------------------------------------------------
18
    */
19
    protected $table = 'med_form_translations';
20
    protected $guarded = ['id'];
21
22
    /*
23
    |--------------------------------------------------------------------------
24
    | FUNCTIONS
25
    |--------------------------------------------------------------------------
26
    */
27
    protected $fillable = [
28
        'title',
29
        'description',
30
        'slug',
31
        'header',
32
        'footer',
33
        'locale',
34
        'form_id',
35
        'text_button',
36
    ];
37
38
    /*
39
    |--------------------------------------------------------------------------
40
    | RELATIONS
41
    |--------------------------------------------------------------------------
42
    */
43
    public function formbuilder()
44
    {
45
        return $this->belongsTo(Formbuilder::class, 'form_id');
46
    }
47
    public function getActivitylogOptions(): LogOptions
48
    {
49
        return LogOptions::defaults()
50
            ->logOnly([
51
                'title',
52
                'text_button',
53
                'slug',
54
                'locale',
55
                'description',
56
                'header',
57
                'footer',
58
                'form_id',
59
                'created_at',
60
                'updated_at'
61
            ])
62
63
            ->logOnlyDirty()
64
            ->dontSubmitEmptyLogs()
65
            ->setDescriptionForEvent(
66
                fn(string $eventName) => ("activity.action.{$eventName}")
67
            )
68
            ->useLogName('form_translation');
69
    }
70
}
71