Skip to content

Commit

Permalink
Update packages.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna authored Jul 28, 2023
1 parent 52267aa commit e5fcfb3
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion draft/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,57 @@ In the `boot` method of your service provider, you can define permissions for yo

## Layouts

// ...
The `Layouts` class is grouping several ones; to add a new feature to it, it is enough to specify it in the service provider as:

```php
use Orchid\Screen\Layout;
use Orchid\Screen\LayoutFactory;
use Orchid\Screen\Repository;

LayoutFactory::macro('hello', function (string $name) {
return new class($name) extends Layout
{
/**
* @ string
*/
public $name;

/**
* Hello constructor.
*
* @param string $name
*/
public function __construct(string $name)
{
$this->name = $name;
}

/**
* @param Repository $repository
*
* @return mixed
*/
protected function build(Repository $repository)
{
return view('hello')->with('name', $this->name);
}

};
});
```

Then on the screen, the call will look like:

```php
use Orchid\Support\Facades\Layout;

public function layout(): array
{
return [
Layout::hello('Alexandr Chernyaev')
];
}
```

## Icons

Expand Down

0 comments on commit e5fcfb3

Please sign in to comment.