vito/app/Web/Components/Link.php
2024-10-06 21:46:03 +02:00

27 lines
617 B
PHP

<?php
namespace App\Web\Components;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class Link extends Component implements Htmlable
{
public function __construct(public string $href, public string $text, public bool $external = false) {}
public function render(): View
{
return view('components.link');
}
public function toHtml(): View|string
{
return $this->render()->with([
'href' => $this->href,
'text' => $this->text,
'external' => $this->external,
]);
}
}