Skip to content

Commit 0a27a08

Browse files
authored
fix: check correct resource on CreateRelatedRecord
fix: check correct resource on CreateRelatedRecord
2 parents 8b38fb1 + ee0a7a0 commit 0a27a08

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Pages/CreateRelatedRecord.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ public function getRecord(): Model
8181

8282
protected function authorizeAccess(): void
8383
{
84-
// TODO: maybe need to switch resource to other resource
85-
abort_unless(static::getResource()::canCreate(), 403);
84+
abort_unless(Filament::getModelResource($this->getRelation()->getRelated())::canCreate(), 403);
8685
}
8786

8887
protected function fillForm(): void
@@ -181,7 +180,7 @@ protected function handleRecordCreation(array $data): Model
181180
}
182181

183182
if (
184-
static::getResource()::isScopedToTenant() &&
183+
Filament::getModelResource($record)::isScopedToTenant() &&
185184
($tenant = Filament::getTenant())
186185
) {
187186
return $this->associateRecordWithTenant($record, $tenant);
@@ -207,7 +206,7 @@ protected function associateRecordWithParent(Model $record, Model $owner)
207206

208207
protected function associateRecordWithTenant(Model $record, Model $tenant): Model
209208
{
210-
$relationship = static::getResource()::getTenantRelationship($tenant);
209+
$relationship = Filament::getModelResource($record)::getTenantRelationship($tenant);
211210

212211
if ($relationship instanceof HasManyThrough) {
213212
$record->save();

0 commit comments

Comments
 (0)