'json' ]; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = []; protected static function booted() { parent::booted(); // TODO: Change the autogenerated stub self::saving(function (Banner $banner) { if (empty($banner->start_time)) { $banner->start_time = Carbon::now()->toDateTimeString(); } }); } public function getUrlAttribute() { if (array_key_exists('cover', $this->attributes)) return path_to_url($this->attributes['cover']); return ''; } public function scopeActive($query) { $now = Carbon::now(); return $query->where('start_time', '<=', $now)->where('end_time', '>=', $now); } }