Forms\Components\Select with relationship loads all records from DB

My code
...
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('author_id')
->relationship('author', 'name')
...
...
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('author_id')
->relationship('author', 'name')
...
Post.php - Model
...

public function author(): BelongsTo
{
return $this
->belongsTo(User::class, 'author_id');
}

...
...

public function author(): BelongsTo
{
return $this
->belongsTo(User::class, 'author_id');
}

...
From DB selects all users. Its all table records.. (not enogth RAM) Also from people table is the same.. DB
SELECT "users"."name", "users"."id" FROM "users" ORDER BY "users"."name" ASC
SELECT "users"."name", "users"."id" FROM "users" ORDER BY "users"."name" ASC
And PHP crashed because off memory exhausted..
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server