mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-28 03:26:29 +08:00
feature: Resource page generics (#17931)
This commit is contained in:
@@ -33,6 +33,8 @@ use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* @template TModel of Model = Model
|
||||
*
|
||||
* @property-read Schema $form
|
||||
*/
|
||||
class EditRecord extends Page
|
||||
@@ -41,7 +43,9 @@ class EditRecord extends Page
|
||||
use Concerns\HasRelationManagers {
|
||||
getContentTabComponent as getBaseContentTabComponent;
|
||||
}
|
||||
use Concerns\InteractsWithRecord;
|
||||
use Concerns\InteractsWithRecord {
|
||||
getRecord as getBaseRecord;
|
||||
}
|
||||
use HasUnsavedDataChangesAlert;
|
||||
|
||||
/**
|
||||
@@ -466,4 +470,12 @@ class EditRecord extends Page
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TModel
|
||||
*/
|
||||
public function getRecord(): Model
|
||||
{
|
||||
return $this->getBaseRecord();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,15 @@ use Livewire\Attributes\Url;
|
||||
|
||||
use function Filament\authorize;
|
||||
|
||||
/**
|
||||
* @template TModel of Model = Model
|
||||
*/
|
||||
class ManageRelatedRecords extends Page implements Tables\Contracts\HasTable
|
||||
{
|
||||
use Concerns\HasRelationManagers;
|
||||
use Concerns\InteractsWithRecord;
|
||||
use Concerns\InteractsWithRecord {
|
||||
getRecord as getBaseRecord;
|
||||
}
|
||||
use InteractsWithRelationshipTable;
|
||||
|
||||
public ?string $previousUrl = null;
|
||||
@@ -330,4 +335,12 @@ class ManageRelatedRecords extends Page implements Tables\Contracts\HasTable
|
||||
'relationship' => static::getRelationshipTitle(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TModel
|
||||
*/
|
||||
public function getRecord(): Model
|
||||
{
|
||||
return $this->getBaseRecord();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @template TModel of Model = Model
|
||||
*
|
||||
* @property-read Schema $form
|
||||
*/
|
||||
class ViewRecord extends Page
|
||||
@@ -27,7 +29,9 @@ class ViewRecord extends Page
|
||||
use Concerns\HasRelationManagers {
|
||||
getContentTabComponent as getBaseContentTabComponent;
|
||||
}
|
||||
use Concerns\InteractsWithRecord;
|
||||
use Concerns\InteractsWithRecord {
|
||||
getRecord as getBaseRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array<string, mixed> | null
|
||||
@@ -234,4 +238,12 @@ class ViewRecord extends Page
|
||||
{
|
||||
return $this->hasInfolist() ? 'infolist' : parent::getDefaultTestingSchemaName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TModel
|
||||
*/
|
||||
public function getRecord(): Model
|
||||
{
|
||||
return $this->getBaseRecord();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user