name = $name; $this->data = $data; $this->parentAttributes = new Attributes(); } /** * @param string $name * @param array $data * * @return static */ public static function create(string $name, array $data = []) { $view = new static($name, $data); if (array_key_exists('url', $data)) { $view->setUrl($data['url']); } return $view; } /** * @return string */ public function render(): string { return view($this->name) ->with($this->data + ['active' => $this->isActive()]) ->render(); } }