'array']; protected $appends = ['tags']; public function level(){ return $this->belongsTo(DiaryMoodLevel::class, 'level_id', 'id'); } public function getTagsAttribute() { $tagArr = json_decode($this->attributes['tag'], TRUE); return $tagArr ? DiaryMoodTag::whereIn('id', $tagArr)->orderByRaw('`rank` desc, `id` desc')->get(['id','name','color']) : []; } }