|
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 FormFieldTranslation extends Model |
|
10
|
|
|
{ |
|
11
|
|
|
use CrudTrait; |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/* |
|
14
|
|
|
|-------------------------------------------------------------------------- |
|
15
|
|
|
| GLOBAL VARIABLES |
|
16
|
|
|
|-------------------------------------------------------------------------- |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $table = 'med_form_field_translations'; |
|
19
|
|
|
protected $guarded = ['id']; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* The attributes that are mass assignable. |
|
23
|
|
|
* |
|
24
|
|
|
* @var array |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $fillable = [ |
|
27
|
|
|
'form_field_id', |
|
28
|
|
|
'locale', |
|
29
|
|
|
'label', |
|
30
|
|
|
'description', |
|
31
|
|
|
'placeholder', |
|
32
|
|
|
'default_value', |
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
/* |
|
36
|
|
|
|-------------------------------------------------------------------------- |
|
37
|
|
|
| FUNCTIONS |
|
38
|
|
|
|-------------------------------------------------------------------------- |
|
39
|
|
|
*/ |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
/* |
|
43
|
|
|
|-------------------------------------------------------------------------- |
|
44
|
|
|
| RELATIONS |
|
45
|
|
|
|-------------------------------------------------------------------------- |
|
46
|
|
|
*/ |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Get the form field that owns the translation |
|
50
|
|
|
*/ |
|
51
|
|
|
public function formField() |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->belongsTo(FormField::class, 'form_field_id'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/* |
|
57
|
|
|
|-------------------------------------------------------------------------- |
|
58
|
|
|
| SCOPES |
|
59
|
|
|
|-------------------------------------------------------------------------- |
|
60
|
|
|
*/ |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Scope a query to only include translations for a specific locale. |
|
64
|
|
|
* |
|
65
|
|
|
* @param \Illuminate\Database\Eloquent\Builder $query |
|
66
|
|
|
* @param string $locale |
|
67
|
|
|
* @return \Illuminate\Database\Eloquent\Builder |
|
68
|
|
|
*/ |
|
69
|
|
|
public function scopeLocale($query, $locale) |
|
70
|
|
|
{ |
|
71
|
|
|
return $query->where('locale', $locale); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/* |
|
75
|
|
|
|-------------------------------------------------------------------------- |
|
76
|
|
|
| ACCESSORS |
|
77
|
|
|
|-------------------------------------------------------------------------- |
|
78
|
|
|
*/ |
|
79
|
|
|
|
|
80
|
|
|
/* |
|
81
|
|
|
|-------------------------------------------------------------------------- |
|
82
|
|
|
| MUTATORS |
|
83
|
|
|
|-------------------------------------------------------------------------- |
|
84
|
|
|
*/ |
|
85
|
|
|
} |
|
86
|
|
|
|