Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
25.00% |
1 / 4 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| BrandStat | |
25.00% |
1 / 4 |
|
0.00% |
0 / 2 |
6.80 | |
0.00% |
0 / 1 |
| booted | |
33.33% |
1 / 3 |
|
0.00% |
0 / 1 |
3.19 | |||
| 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 | class BrandStat extends Model |
| 8 | { |
| 9 | /** |
| 10 | * Indicates if the model should be timestamped. |
| 11 | * |
| 12 | * @var boolean |
| 13 | */ |
| 14 | public $timestamps = false; |
| 15 | |
| 16 | /** |
| 17 | * The attributes that should be cast to native types. |
| 18 | * |
| 19 | * @var array |
| 20 | */ |
| 21 | public $casts = [ |
| 22 | 'created_at' => 'date' |
| 23 | ]; |
| 24 | |
| 25 | /** |
| 26 | * The attributes that are mass assignable. |
| 27 | * |
| 28 | * @var string[] |
| 29 | */ |
| 30 | protected $fillable = [ |
| 31 | 'active', 'inactive', |
| 32 | 'old_accounts', 'new_accounts', |
| 33 | 'total_accounts', 'total_opt_in' |
| 34 | ]; |
| 35 | |
| 36 | /** |
| 37 | * Perform any actions required after the model boots. |
| 38 | * |
| 39 | * @return void |
| 40 | */ |
| 41 | protected static function booted() |
| 42 | { |
| 43 | static::creating(function (self $model) { |
| 44 | if (!$model->created_at) { |
| 45 | $model->created_at = now(); |
| 46 | } |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | // * RELATIONS |
| 51 | |
| 52 | /** |
| 53 | * Brand hasMany relation |
| 54 | * |
| 55 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 56 | */ |
| 57 | public function brand() |
| 58 | { |
| 59 | return $this->belongsTo(Brand::class); |
| 60 | } |
| 61 | } |