ldc-crm/app/Models/BrandStat.php
Jérémy Munsch 9f6ae7bd09
Stats graphs
2021-11-03 11:18:19 +01:00

36 lines
686 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
class BrandStat extends Model
{
public $timestamps = false;
public $casts = [
'created_at' => 'date'
];
protected $fillable = [
'active', 'inactive',
'old_accounts', 'new_accounts',
'total_accounts', 'total_opt_in'
];
protected static function booted()
{
static::creating(function (BrandStat $stat) {
if (!$stat->created_at) {
$stat->created_at = Carbon::now();
}
});
}
public function brand()
{
return $this->belongsTo(Brand::class);
}
}