33 lines
864 B
PHP
33 lines
864 B
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use Filament\Actions\Action;
|
|
use Filament\Resources\Pages\Page;
|
|
|
|
trait HasBackUrl
|
|
{
|
|
/**
|
|
* überschreibt in EditRecords CancelAction da diese history based schritt für schit zurück ging.
|
|
* mit diese änderung füht der Link direct zurück zur projekte liste.
|
|
*/
|
|
public ?string $backUrl = null;
|
|
|
|
public function mount($record = null): void
|
|
{
|
|
$this->backUrl = url()->previous();
|
|
parent::mount($record);
|
|
}
|
|
|
|
protected function getRedirectUrl(): string // <- return type is string to be compatible with EditRecord & CreateRecord
|
|
{
|
|
return $this->backUrl;
|
|
}
|
|
|
|
protected function getCancelFormAction(): Action
|
|
{
|
|
return parent::getCancelFormAction()
|
|
->url(fn (Page $livewire) => $livewire->backUrl ?? static::getResource()::getUrl());
|
|
}
|
|
}
|