F
Filamentā€¢7mo ago
gigiloouu

error it cant see my table columns

It was working but now it doest works idk why.. when i create supplier it cant see brands and subbrands. there is my code also:
return $form
->schema([
TextInput::make('name')
->required()
->maxLength(255)
->minLength(2),
Select::make('brand_id')
->label('Brand')
->multiple()
->relationship('brand', 'name')
->searchable()
->required()
->options(Brand::all()->pluck('name', 'id'))
->preload()
->createOptionForm([
TextInput::make('name')
->required()
->label('New Brand'),
]),
Select::make('subbrand_id')
->label('Subbrand')
->multiple()
->relationship('subbrand', 'name')
->searchable()
->options(Subbrand::all()->pluck('name', 'id'))
->columnSpan('full')
->preload()
->createOptionForm([
TextInput::make('name')
->required()
->label('New Subbrand'),
]),
]);
}
return $form
->schema([
TextInput::make('name')
->required()
->maxLength(255)
->minLength(2),
Select::make('brand_id')
->label('Brand')
->multiple()
->relationship('brand', 'name')
->searchable()
->required()
->options(Brand::all()->pluck('name', 'id'))
->preload()
->createOptionForm([
TextInput::make('name')
->required()
->label('New Brand'),
]),
Select::make('subbrand_id')
->label('Subbrand')
->multiple()
->relationship('subbrand', 'name')
->searchable()
->options(Subbrand::all()->pluck('name', 'id'))
->columnSpan('full')
->preload()
->createOptionForm([
TextInput::make('name')
->required()
->label('New Subbrand'),
]),
]);
}
Supplier Model:
No description
No description
No description
49 Replies
gigiloouu
gigiloouuā€¢7mo ago
any ideas?
ericmp
ericmpā€¢7mo ago
not sure, but an optimisation:
Brand::all()->pluck('name', 'id')
Brand::all()->pluck('name', 'id')
to
Brand::pluck('name', 'id')
Brand::pluck('name', 'id')
\Illuminate\Support\Benchmark::dd([
fn () => Brand::all()->pluck('name', 'id'),
fn () => Brand::pluck('name', 'id'),
]);
\Illuminate\Support\Benchmark::dd([
fn () => Brand::all()->pluck('name', 'id'),
fn () => Brand::pluck('name', 'id'),
]);
gigiloouu
gigiloouuā€¢7mo ago
where i should write this ?
\Illuminate\Support\Benchmark::dd([
fn () => Brand::all()->pluck('name', 'id'),
fn () => Brand::pluck('name', 'id'),
]);
\Illuminate\Support\Benchmark::dd([
fn () => Brand::all()->pluck('name', 'id'),
fn () => Brand::pluck('name', 'id'),
]);
ericmp
ericmpā€¢7mo ago
in tinker for example - php artisan tinker add \App\Models\ before the model name
gigiloouu
gigiloouuā€¢7mo ago
i should write it in model?
ericmp
ericmpā€¢7mo ago
no, i mean, like this:
\Illuminate\Support\Benchmark::dd([
fn () => \App\Models\Brand::all()->pluck('name', 'id'),
fn () => \App\Models\Brand::pluck('name', 'id'),
]);
\Illuminate\Support\Benchmark::dd([
fn () => \App\Models\Brand::all()->pluck('name', 'id'),
fn () => \App\Models\Brand::pluck('name', 'id'),
]);
gigiloouu
gigiloouuā€¢7mo ago
okay and where i should writ eit ? aa in terminal?
ericmp
ericmpā€¢7mo ago
if u do php artisan tinker u can execute arbitrary code yes thats an option
gigiloouu
gigiloouuā€¢7mo ago
No description
gigiloouu
gigiloouuā€¢7mo ago
i got it what is it ? šŸ’€
ericmp
ericmpā€¢7mo ago
the benchmark results xd
gigiloouu
gigiloouuā€¢7mo ago
amm and its works or what? dd is it good ? ddd idk in web i have same result it cant read brand_ids and subbrand_ids
gigiloouu
gigiloouuā€¢7mo ago
No description
gigiloouu
gigiloouuā€¢7mo ago
its doest takes brand_id and subbrand_id literally yesterday it was working dd just i remove db and create again but in db everything is okay i think becouse by hand in db its works just there..
ericmp
ericmpā€¢7mo ago
in the 1st message i sent, literally the 2 first words are "not sure", which i meant idk what is happening with ur code. then i just wanted u to notice that Brand::all()->pluck('name', 'id') could be optimised. that is why i showed u the benchmark thing, so u can see the difference. that is it.
Want results from more Discord servers?
Add your server