F
Filament2mo ago
Nobody

Why when I deploy Filament on the server the data dropdown is empty?

So I have a select Head Partner that takes user data whose is_head is 1 but why is the dropdwon data empty. even though I make sure the user data whose is_head is 1 exists this is the code
Forms\Components\Select::make('parent_id')
->label('Head Partner')
->searchable()
->options(function () {
$headUsers = User::where('is_head', 1)->get(['id', 'name', 'is_head']);
$headUsers->each(function ($user) {
Log::info('Head User Found:', ['id' => $user->id, 'name' => $user->name, 'is_head' => $user->is_head]);
});
return $headUsers->pluck('name', 'id');
})
->required()
->reactive()
->visible(fn(callable $get) => $get('is_head') === false)
->live(),
Forms\Components\Select::make('parent_id')
->label('Head Partner')
->searchable()
->options(function () {
$headUsers = User::where('is_head', 1)->get(['id', 'name', 'is_head']);
$headUsers->each(function ($user) {
Log::info('Head User Found:', ['id' => $user->id, 'name' => $user->name, 'is_head' => $user->is_head]);
});
return $headUsers->pluck('name', 'id');
})
->required()
->reactive()
->visible(fn(callable $get) => $get('is_head') === false)
->live(),
So I have a select Head Partner that takes user data whose is_head is 1 but why is the dropdwon data empty. even though I make sure the user data whose is_head is 1 exists this is the code Here I try to log the head user data and the data is there and is_head 1 this is the laravel.log [2024-10-21 03:34:48] local.INFO: Head User Found: {"id":18,"name":"Hyundai Jakarta","is_head":1} [2024-10-21 03:34:48] local.INFO: Head User Found: {"id":20,"name":"Honda Jakarta","is_head":1} Does anyone know why the data doesn't appear in the head partner dropdown? note: in local it works fine with the same code
No description
No description
Solution:
I added code like this in AppServiceProviders.php ``` if (config('app.env') !== 'local') { // pastikan hanya di production/staging URL::forceScheme('https');...
Jump to solution
10 Replies
Dennis Koch
Dennis Koch2mo ago
Please read the #✅┊rules on how to format code. Looks like the select isn't properly initialiazed. Do you have any JS errors in the console?
Nobody
NobodyOP2mo ago
oh sorry I fixed it yes in the chrome browser console there is an error like this. Why is there an error like this? Is there something that needs to be fixed on the server?
No description
Dennis Koch
Dennis Koch2mo ago
What do those files return? Is there an error? Different content than the actual JS? Do those assets exist?
Nobody
NobodyOP2mo ago
I clicked this file to generate code like this This code is automatically generated when installing filament? because I don't think I made that code
No description
Dennis Koch
Dennis Koch2mo ago
This code is automatically generated when installing filament?
Yes. Hm, looks good to me
Nobody
NobodyOP2mo ago
so why does it get an error here? do you have a solution for this
Dennis Koch
Dennis Koch2mo ago
Any errors in the network tab?
Nobody
NobodyOP2mo ago
yes there is an error like this
No description
Dennis Koch
Dennis Koch2mo ago
Mixed Content means you are loading assets from HTTP when using HTTPS. Either your APP_URL is wrong or you need URL::forceScheme('https'); in your service provider
Solution
Nobody
Nobody2mo ago
I added code like this in AppServiceProviders.php
if (config('app.env') !== 'local') { // pastikan hanya di production/staging
URL::forceScheme('https');
}
if (config('app.env') !== 'local') { // pastikan hanya di production/staging
URL::forceScheme('https');
}
and it works thank you very much
Want results from more Discord servers?
Add your server