morphTo(); } /** * User * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function user() { return $this->belongsTo('User'); } public function scopeDateIs($query, Carbon $start, Carbon $end) { return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d')); } public function getDataAttribute($value) { return json_decode($value); } /** * @param $value */ public function setDataAttribute($value) { $this->attributes['data'] = json_encode($value); } }