Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
40.00% |
2 / 5 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| BrandStat | |
40.00% |
2 / 5 |
|
0.00% |
0 / 2 |
4.94 | |
0.00% |
0 / 1 |
| booted | |
50.00% |
2 / 4 |
|
0.00% |
0 / 1 |
2.50 | |||
| brand | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | |
| 7 | /** |
| 8 | * @property integer $active |
| 9 | * @property integer $inactive |
| 10 | * @property integer $old_accounts |
| 11 | * @property integer $new_accounts |
| 12 | * @property integer $total_accounts |
| 13 | * @property integer $total_opt_in |
| 14 | * @property integer $brand_id Foreign key Brand. |
| 15 | * @property-read \Illuminate\Support\Carbon $created_at Created date. |
| 16 | * |
| 17 | * @property-read \App\Models\Brand $brand Brand BelongsTo relation. |
| 18 | */ |
| 19 | class BrandStat extends Model |
| 20 | { |
| 21 | /** |
| 22 | * Indicates if the model should be timestamped. |
| 23 | * |
| 24 | * @var boolean |
| 25 | */ |
| 26 | public $timestamps = false; |
| 27 | |
| 28 | /** |
| 29 | * The attributes that are mass assignable. |
| 30 | * |
| 31 | * @var string[] |
| 32 | */ |
| 33 | protected $fillable = [ |
| 34 | 'active', |
| 35 | 'inactive', |
| 36 | 'old_accounts', |
| 37 | 'new_accounts', |
| 38 | 'total_accounts', |
| 39 | 'total_opt_in', |
| 40 | ]; |
| 41 | |
| 42 | /** |
| 43 | * The attributes that should be cast to native types. |
| 44 | * |
| 45 | * @var array |
| 46 | */ |
| 47 | public $casts = [ |
| 48 | 'created_at' => 'date', |
| 49 | ]; |
| 50 | |
| 51 | /** |
| 52 | * Perform any actions required after the model boots. |
| 53 | * |
| 54 | * @return void |
| 55 | */ |
| 56 | protected static function booted(): void |
| 57 | { |
| 58 | static::creating(function (self $model) { |
| 59 | if (!$model->created_at) { |
| 60 | $model->created_at = now(); |
| 61 | } |
| 62 | }); |
| 63 | } |
| 64 | |
| 65 | // * RELATIONS |
| 66 | |
| 67 | /** |
| 68 | * Brand hasMany relation. |
| 69 | * |
| 70 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 71 | */ |
| 72 | public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 73 | { |
| 74 | return $this->belongsTo(Brand::class); |
| 75 | } |
| 76 | } |