Skip to content

Commit

Permalink
Update packages.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna authored Aug 12, 2024
1 parent e134af3 commit 9a08909
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions docs/en/docs/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,59 @@ Orchid\Platform\Dashboard::version()
```

This constant returns a string representation of the current version being used.


## Extending 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')
];
}
```

0 comments on commit 9a08909

Please sign in to comment.