only(['descriptor', 'id']) ->mapWithKeys(function($item,$key) { if ($key == 'id') { return ['id' => $item]; } return ['name' => $item]; })->toArray(); return (new self($item)); } public function getNameAttribute() { return ucfirst($this->attributes['name']); } public function getIsNullAttribute() { return $this->attributes['id'] == self::getNullValue(); } }