*/ protected $casts = [ 'id' => 'integer', 'parent_id' => '?integer', 'code' => 'string', 'apple_category' => 'string', 'google_category' => 'string', ]; public function getParent(): ?self { if ($this->parent_id === null) { return null; } return (new CategoryModel())->getCategoryById($this->parent_id); } }