Расширение слоёв
Suggest EditКласс Layouts является группирующим нескольких различных. Для того чтобы добавить в него новую возможность, достаточно указать её в сервис провайдере как:
use Orchid\Screen\Layouts\Base;
use Orchid\Screen\Repository;
use Orchid\Screen\Layout;
Layout::macro('hello', function (string $name) {
return new class($name) extends Base
{
/**
* @ string
*/
public $name;
/**
* Hello constructor.
*
* @param string $name
*/
public function __construct(string $name)
{
$this->name = $name;
}
/**
* @param Repository $repository
*
* @return mixed
*/
public function build(Repository $repository)
{
return view('hello')->with('name', $this->name);
}
};
});
Тогда в экране вызов будет выглядеть как:
public function layout(): array
{
return [
Layout::hello('Alexandr Chernyaev')
];
}