2021-10-29 12:53:46 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
2023-09-06 17:24:53 +02:00
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2021-10-29 12:53:46 +02:00
|
|
|
class BrandStat extends Model
|
|
|
|
|
{
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* Indicates if the model should be timestamped.
|
|
|
|
|
*
|
|
|
|
|
* @var boolean
|
|
|
|
|
*/
|
2021-10-29 12:53:46 +02:00
|
|
|
public $timestamps = false;
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
2023-09-04 13:08:34 +02:00
|
|
|
* The attributes that are mass assignable.
|
2021-12-19 15:57:24 +01:00
|
|
|
*
|
2025-07-24 11:32:12 +02:00
|
|
|
* @var array<int, string>
|
2021-12-19 15:57:24 +01:00
|
|
|
*/
|
2023-09-04 13:08:34 +02:00
|
|
|
protected $fillable = [
|
|
|
|
|
'active',
|
|
|
|
|
'inactive',
|
|
|
|
|
'old_accounts',
|
|
|
|
|
'new_accounts',
|
|
|
|
|
'total_accounts',
|
|
|
|
|
'total_opt_in',
|
2021-10-29 12:53:46 +02:00
|
|
|
];
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
2023-09-04 13:08:34 +02:00
|
|
|
* The attributes that should be cast to native types.
|
2021-12-19 15:57:24 +01:00
|
|
|
*
|
2025-07-24 11:32:12 +02:00
|
|
|
* @var array<string, mixed>
|
2021-12-19 15:57:24 +01:00
|
|
|
*/
|
2023-09-04 13:08:34 +02:00
|
|
|
public $casts = [
|
|
|
|
|
'created_at' => 'date',
|
2021-10-29 12:53:46 +02:00
|
|
|
];
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* Perform any actions required after the model boots.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2023-09-06 17:24:53 +02:00
|
|
|
protected static function booted(): void
|
2021-10-29 12:53:46 +02:00
|
|
|
{
|
2023-06-26 14:38:26 +02:00
|
|
|
static::creating(function (self $model) {
|
|
|
|
|
if (!$model->created_at) {
|
|
|
|
|
$model->created_at = now();
|
2021-11-03 11:18:19 +01:00
|
|
|
}
|
2021-10-29 12:53:46 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
// * RELATIONS
|
|
|
|
|
|
|
|
|
|
/**
|
2025-07-24 11:32:12 +02:00
|
|
|
* Brand belongs to relation.
|
2021-12-19 15:57:24 +01:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
|
*/
|
2023-09-06 17:24:53 +02:00
|
|
|
public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2021-10-29 12:53:46 +02:00
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Brand::class);
|
|
|
|
|
}
|
|
|
|
|
}
|