mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
fix
This commit is contained in:
+5
-7
@@ -22,13 +22,6 @@ class Page extends Component
|
||||
|
||||
public static $view;
|
||||
|
||||
public function __invoke(Container $container, \Illuminate\Routing\Route $route)
|
||||
{
|
||||
abort_unless($this->isAuthorized(), 403);
|
||||
|
||||
return parent::__invoke($container, $route);
|
||||
}
|
||||
|
||||
public static function authorization()
|
||||
{
|
||||
return [];
|
||||
@@ -95,6 +88,11 @@ class Page extends Component
|
||||
return Filament::can('view', static::class);
|
||||
}
|
||||
|
||||
protected function abortIfForbidden()
|
||||
{
|
||||
abort_unless($this->isAuthorized(), 403);
|
||||
}
|
||||
|
||||
public static function navigationItems()
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -74,6 +74,8 @@ class CreateRecord extends Page
|
||||
public function mount()
|
||||
{
|
||||
$this->fillRecord();
|
||||
|
||||
$this->abortIfForbidden();
|
||||
}
|
||||
|
||||
protected function actions()
|
||||
|
||||
@@ -68,6 +68,8 @@ class EditRecord extends Page
|
||||
public function mount($record)
|
||||
{
|
||||
$this->fillRecord($record);
|
||||
|
||||
$this->abortIfForbidden();
|
||||
}
|
||||
|
||||
public function save()
|
||||
@@ -102,21 +104,28 @@ class EditRecord extends Page
|
||||
];
|
||||
}
|
||||
|
||||
protected function fillRecord($record)
|
||||
protected function fillRecord($key)
|
||||
{
|
||||
$this->callHook('beforeFill');
|
||||
|
||||
$model = static::getModel();
|
||||
|
||||
$this->record = (new $model())->resolveRouteBinding($record);
|
||||
|
||||
if ($this->record === null) {
|
||||
throw (new ModelNotFoundException())->setModel($model, [$record]);
|
||||
}
|
||||
$this->record = $this->resolveRecord($key);
|
||||
|
||||
$this->callHook('afterFill');
|
||||
}
|
||||
|
||||
protected function resolveRecord($key)
|
||||
{
|
||||
$model = static::getModel();
|
||||
|
||||
$record = (new $model())->resolveRouteBinding($key);
|
||||
|
||||
if ($record === null) {
|
||||
throw (new ModelNotFoundException())->setModel($model, [$key]);
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
protected function form(Form $form)
|
||||
{
|
||||
return static::getResource()::form(
|
||||
|
||||
@@ -107,4 +107,9 @@ class ListRecords extends Page
|
||||
'records' => $this->getRecords(),
|
||||
];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->abortIfForbidden();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class EditRecord extends Component
|
||||
$this->record = [];
|
||||
}
|
||||
|
||||
public function switchRecord($manager, $record)
|
||||
public function switchRecord($manager, $recordKey)
|
||||
{
|
||||
if ($manager !== $this->manager) {
|
||||
return;
|
||||
@@ -93,7 +93,7 @@ class EditRecord extends Component
|
||||
|
||||
$this->callHook('beforeFill');
|
||||
|
||||
$this->record = $this->getQuery()->find($record);
|
||||
$this->record = $this->getQuery()->find($recordKey);
|
||||
$this->resetTemporaryUploadedFiles();
|
||||
|
||||
$this->callHook('afterFill');
|
||||
|
||||
Reference in New Issue
Block a user