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')
...

Post.php - Model

...

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

And PHP crashed because off memory exhausted..
Was this page helpful?