Laravel-Backpack /
CRUD
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Backpack\CRUD\Tests\Config\Models; |
||
| 4 | |||
| 5 | use Backpack\CRUD\app\Models\Traits\CrudTrait; |
||
| 6 | use Illuminate\Database\Eloquent\Casts\Attribute; |
||
| 7 | use Illuminate\Database\Eloquent\Model; |
||
| 8 | |||
| 9 | class AccountDetails extends Model |
||
| 10 | { |
||
| 11 | use CrudTrait; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 12 | |||
| 13 | protected $table = 'account_details'; |
||
| 14 | protected $fillable = ['user_id', 'nickname', 'profile_picture', 'article_id', 'start_date', 'end_date']; |
||
| 15 | |||
| 16 | public function identifiableAttribute() |
||
| 17 | { |
||
| 18 | return 'nickname'; |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Get the user for the account details. |
||
| 23 | */ |
||
| 24 | public function user() |
||
| 25 | { |
||
| 26 | return $this->belongsTo('Backpack\CRUD\Tests\config\Models\User'); |
||
| 27 | } |
||
| 28 | |||
| 29 | public function addresses() |
||
| 30 | { |
||
| 31 | return $this->hasMany('Backpack\CRUD\Tests\config\Models\Address'); |
||
| 32 | } |
||
| 33 | |||
| 34 | public function getNicknameComposedAttribute() |
||
| 35 | { |
||
| 36 | return $this->nickname.'++'; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function article() |
||
| 40 | { |
||
| 41 | return $this->belongsTo('Backpack\CRUD\Tests\config\Models\Article'); |
||
| 42 | } |
||
| 43 | |||
| 44 | public function bangs() |
||
| 45 | { |
||
| 46 | return $this->belongsToMany('Backpack\CRUD\Tests\config\Models\Bang'); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function bangsPivot() |
||
| 50 | { |
||
| 51 | return $this->belongsToMany('Backpack\CRUD\Tests\config\Models\Bang', 'account_details_bangs_pivot')->withPivot('pivot_field'); |
||
| 52 | } |
||
| 53 | |||
| 54 | public function nicknamutator(): Attribute |
||
| 55 | { |
||
| 56 | return Attribute::get(fn ($value) => strtoupper($value)); |
||
| 57 | } |
||
| 58 | } |
||
| 59 |