mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
clean up and docs
This commit is contained in:
@@ -486,6 +486,18 @@ MenuItem::make()
|
||||
->hidden(fn (): bool => ! auth()->user()->can('viewAny', Payment::class))
|
||||
```
|
||||
|
||||
### Sending a `POST` HTTP request from a user menu item
|
||||
|
||||
You can send a `POST` HTTP request from a user menu item by passing a URL to the `postAction()` method:
|
||||
|
||||
```php
|
||||
use Filament\Navigation\MenuItem;
|
||||
|
||||
MenuItem::make()
|
||||
->label('Lock session')
|
||||
->postAction(fn (): string => route('lock-session'))
|
||||
```
|
||||
|
||||
## Disabling breadcrumbs
|
||||
|
||||
The default layout will show breadcrumbs to indicate the location of the current page within the hierarchy of the app.
|
||||
|
||||
@@ -435,6 +435,18 @@ MenuItem::make()
|
||||
->hidden(fn (): bool => ! auth()->user()->can('manage-team'))
|
||||
```
|
||||
|
||||
### Sending a `POST` HTTP request from a tenant menu item
|
||||
|
||||
You can send a `POST` HTTP request from a tenant menu item by passing a URL to the `postAction()` method:
|
||||
|
||||
```php
|
||||
use Filament\Navigation\MenuItem;
|
||||
|
||||
MenuItem::make()
|
||||
->label('Lock session')
|
||||
->postAction(fn (): string => route('lock-session'))
|
||||
```
|
||||
|
||||
### Hiding the tenant menu
|
||||
|
||||
You can hide the tenant menu by using the `tenantMenu(false)`
|
||||
|
||||
@@ -116,12 +116,18 @@
|
||||
@if (count($items))
|
||||
<x-filament::dropdown.list>
|
||||
@foreach ($items as $item)
|
||||
@php
|
||||
$itemPostAction = $item->getPostAction();
|
||||
@endphp
|
||||
|
||||
<x-filament::dropdown.list.item
|
||||
:action="$itemPostAction"
|
||||
:color="$item->getColor()"
|
||||
:href="$item->getUrl()"
|
||||
:target="$item->shouldOpenUrlInNewTab() ? '_blank' : null"
|
||||
:icon="$item->getIcon()"
|
||||
tag="a"
|
||||
:method="filled($itemPostAction) ? 'post' : null"
|
||||
:tag="filled($itemPostAction) ? 'form' : 'a'"
|
||||
:target="$item->shouldOpenUrlInNewTab() ? '_blank' : null"
|
||||
>
|
||||
{{ $item->getLabel() }}
|
||||
</x-filament::dropdown.list.item>
|
||||
|
||||
@@ -68,16 +68,16 @@
|
||||
<x-filament::dropdown.list>
|
||||
@foreach ($items as $key => $item)
|
||||
@php
|
||||
$itemAction = $item->getAction();
|
||||
$itemPostAction = $item->getPostAction();
|
||||
@endphp
|
||||
|
||||
|
||||
<x-filament::dropdown.list.item
|
||||
:action="$itemAction"
|
||||
:action="$itemPostAction"
|
||||
:color="$item->getColor()"
|
||||
:href="$item->getUrl()"
|
||||
:icon="$item->getIcon()"
|
||||
:method="filled($itemAction) ? 'post' : null"
|
||||
:tag="filled($itemAction) ? 'form' : 'a'"
|
||||
:method="filled($itemPostAction) ? 'post' : null"
|
||||
:tag="filled($itemPostAction) ? 'form' : 'a'"
|
||||
:target="$item->shouldOpenUrlInNewTab() ? '_blank' : null"
|
||||
>
|
||||
{{ $item->getLabel() }}
|
||||
|
||||
@@ -8,6 +8,8 @@ use Laravel\SerializableClosure\Serializers\Native;
|
||||
|
||||
class MenuItem extends Component
|
||||
{
|
||||
protected string | Closure | null $postAction = null;
|
||||
|
||||
/**
|
||||
* @var string | array{50: string, 100: string, 200: string, 300: string, 400: string, 500: string, 600: string, 700: string, 800: string, 900: string, 950: string} | Closure | null
|
||||
*/
|
||||
@@ -21,8 +23,6 @@ class MenuItem extends Component
|
||||
|
||||
protected string | Closure | Native | null $url = null;
|
||||
|
||||
protected string | Closure | null $action = null;
|
||||
|
||||
protected bool | Closure $shouldOpenUrlInNewTab = false;
|
||||
|
||||
protected bool | Closure $isHidden = false;
|
||||
@@ -82,7 +82,7 @@ class MenuItem extends Component
|
||||
|
||||
public function postAction(string | Closure | null $action): static
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->postAction = $action;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -150,9 +150,9 @@ class MenuItem extends Component
|
||||
return $this->evaluate($this->url);
|
||||
}
|
||||
|
||||
public function getAction(): ?string
|
||||
public function getPostAction(): ?string
|
||||
{
|
||||
return $this->evaluate($this->action);
|
||||
return $this->evaluate($this->postAction);
|
||||
}
|
||||
|
||||
public function shouldOpenUrlInNewTab(): bool
|
||||
|
||||
Reference in New Issue
Block a user