forked from laravel/folio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
56 lines (46 loc) · 1.4 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Laravel\Folio;
use Closure;
use Illuminate\Container\Container;
use Illuminate\Support\Arr;
use Laravel\Folio\Options\PageOptions;
/**
* Specify the callback that should be used to render matched views.
*/
function render(callable $callback): PageOptions
{
Container::getInstance()->make(InlineMetadataInterceptor::class)->whenListening(
fn () => Metadata::instance()->renderUsing = $callback,
);
return new PageOptions;
}
/**
* Specify the name of the current page.
*/
function name(string $name): PageOptions
{
Container::getInstance()->make(InlineMetadataInterceptor::class)->whenListening(
fn () => Metadata::instance()->name = $name,
);
return new PageOptions;
}
/**
* Add one or more middleware to the current page.
*/
function middleware(Closure|string|array $middleware = []): PageOptions
{
Container::getInstance()->make(InlineMetadataInterceptor::class)->whenListening(
fn () => Metadata::instance()->middleware = Metadata::instance()->middleware->merge(Arr::wrap($middleware)),
);
return new PageOptions;
}
/**
* Indicate that the current page should include trashed models.
*/
function withTrashed(bool $withTrashed = true): PageOptions
{
Container::getInstance()->make(InlineMetadataInterceptor::class)->whenListening(
fn () => Metadata::instance()->withTrashed = $withTrashed,
);
return new PageOptions;
}