Files
nutzwerte_fi4/app/Traits/HasBackUrl.php
T
2025-11-10 12:59:50 +01:00

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());
}
}