ldc-crm/app/Models/BrandStat.php
Alexis Gousseau 303834bbca
Crm V4
- Make all tests pass Client (V4),CRMV2,CRMV4
- Simplify client submodule path
- Move App_url to .env.testing
2023-10-06 16:37:29 +02:00

76 lines
1.6 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 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
*/
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 hasMany relation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Brand::class);
}
}