ldc-crm/app/Models/BrandStat.php
2025-07-28 09:07:54 +02:00

76 lines
1.7 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $active
* @property integer $inactive
* @property integer $old_accounts
* @property integer $new_accounts
* @property integer $total_accounts
* @property integer $total_opt_in
* @property integer $brand_id Foreign key Brand.
* @property-read \Illuminate\Support\Carbon $created_at Created date.
*
* @property-read \App\Models\Brand $brand Brand BelongsTo relation.
*/
class BrandStat extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'active',
'inactive',
'old_accounts',
'new_accounts',
'total_accounts',
'total_opt_in',
];
/**
* The attributes that should be cast to native types.
*
* @var array<string, mixed>
*/
public $casts = [
'created_at' => 'date',
];
/**
* Perform any actions required after the model boots.
*
* @return void
*/
protected static function booted(): void
{
static::creating(function (self $model) {
if (!$model->created_at) {
$model->created_at = now();
}
});
}
// * RELATIONS
/**
* Brand belongs to relation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Brand::class);
}
}