36 lines
686 B
PHP
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);
|
|
}
|
|
}
|