'array', ]; // protected $guarded = ['year','month']; protected static function booting() { static::creating(function ($model) { $model->day = $model->year . '-' . $model->month ; unset($model->year, $model->month); }); } protected function getMonthAttribute() { return date('m', strtotime($this->day)); } protected function getYearAttribute() { return date('Y', strtotime($this->day)); } protected function getCountDataAttribute() { return @NewMediaCountRecord::where('nmc_id', $this->id)->get()->toArray(); } }