ldc-supportweb/app/Models/Credit/Account.php

85 lines
1.8 KiB
PHP
Raw Normal View History

2022-05-31 14:06:07 +02:00
<?php
namespace App\Models\Credit;
use App\Enums\Credit\AccountTypeEnum;
2022-05-31 14:06:07 +02:00
use App\Models\Brand;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property AccountTypeEnum $type Enum Credit\AccountTypeEnum
* @property string $label Custom account label
* @property float $balance Account balance
* @property int $brand_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read Brand $brand
* @property-read \App\Models\Credit\CreditLog|null $creditlogs
* @mixin \Eloquent
*/
2022-05-31 14:06:07 +02:00
class Account extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'credit_accounts';
/**
* The attributes that are fillable.
2022-05-31 14:06:07 +02:00
*
* @var array
*/
protected $fillable = [
'label',
'type',
'balance',
'brand_id'
2022-05-31 14:06:07 +02:00
];
/**
* The attributes that should be cast.
2022-05-31 14:06:07 +02:00
*
* @var array
*/
protected $casts = [
'type' => AccountTypeEnum::class
2022-05-31 14:06:07 +02:00
];
/**
* Perform any actions required after the model boots.
2022-05-31 14:06:07 +02:00
*
* @return void
2022-05-31 14:06:07 +02:00
*/
protected static function booted()
2022-05-31 14:06:07 +02:00
{
static::deleting(function () {
throw new \Error('Action impossible');
});
2022-05-31 14:06:07 +02:00
}
// * RELATIONSHIPS
/**
* BelongsTo Brand relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function brand()
{
return $this->belongsTo(Brand::class);
}
/**
* HasOne Account relation
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function creditlogs()
{
return $this->HasOne(CreditLog::class, 'credit_account_id');
}
2022-05-31 14:06:07 +02:00
}