public static function getUrl(string $name = 'index', array $parameters = [], bool $isAbsolute = true, ?string $panel = null, ?Model $tenant = null): string
{
if (!isset($parameters['station'])) {
$parameters['station'] = self::getCurrentStation(); //Route::current()->parameter('station')
}
return parent::getUrl($name, $parameters, $isAbsolute, $panel, $tenant);
}
private static function getCurrentStation()
{
$station = request('station');
if(isset($station)){
return $station;
}
//try to get the Model from the previous known route
$previousRoute = Route::getRoutes()->match(request()->create(url()->previousPath()));
if (isset($previousRoute)) {
//the model is not in the request (this is probably a Livewire request)
//reset it
$station = $previousRoute->parameter('station');
request()->merge(['station' => $station]);
return $station;
}
return null;
}
1条答案
按热度按时间thtygnil1#
我认为你是对的; Livewire不接收
station
参数。所以解决方法是每次参数为空时都要设置它。像这样(在你的例子中,EpisodeResource
):也请看这个问题:https://github.com/filamentphp/filament/issues/7104和这个讨论:https://github.com/filamentphp/filament/discussions/6099