-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed as not planned
Closed as not planned
Copy link
Labels
Milestone
Description
Package
filament/filament
Package Version
v3.2.61
Laravel Version
v11.1.0
Livewire Version
v.3.0.0
PHP Version
PHP 8.3.4
Problem description
I installed fresh laravel v11.1.0 and install filament and spatie settings to save my site settings, I follow all the steps to make it running smoothly. I made GeneralSiteSettings page on my panel and using FileUpload::make('logo') to upload my logo to spatie settings, but after setting saved, my page returning error foreach() argument must be of type array|object, string given, for complete error log please visit flare error here [here](https://flareapp.io/share/353KwXo5)
and here the screen capture of the error:

Expected behavior
FileUpload should be able to handle single file upload on any page and any condition (create or update)
Steps to reproduce
- Install fresh laravel
- Install fresh filament and configure it
- Install spatie settings from official repo https://github.com/spatie/laravel-settings and follow the instruction to configure it properly
- Create a simple settings for name, description and logo
- create a blank filament page using command
php artisan make:filament-page GeneralSiteSettings - on GeneralSiteSettings.php, create forms with getFormSchema function, add some form input especially
FileUpload::make('logo')->image()to upload our logo
Here is my complete function:
<?php
namespace App\Filament\Pages;
use App\Settings\SiteSettings;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Split;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
class GeneralSiteSettings extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.general-site-settings';
public ?array $data = [];
public function mount(SiteSettings $settings)
{
$this->data = $settings->toArray();
}
public function getFormSchema(): array
{
return [
Split::make([
Section::make()->schema([
FileUpload::make('logo')
->disk('public')
->image(),
]),
Section::make()->schema([
TextInput::make('name')->required(),
TextInput::make('description'),
])
])->statePath('data')
];
}
public function save(SiteSettings $settings)
{
$data = (object)$this->form->getState()['data'];
$settings->name = $data->name;
$settings->description = $data->description;
$settings->logo = $data->logo;
if($settings->save()) {
return Notification::make()
->success()
->title('Site settings updated')
->body('Settings updated succesfully')->send();
}
return Notification::make()
->danger()
->title('Failed to save settings')
->body('Your settings data failed to update')
->send();
}
}
Reproduction repository
https://github.com/abanghendri/filamentBugReport
Relevant log output
[2024-03-28 15:17:58] local.ERROR: foreach() argument must be of type array|object, string given {"userId":1,"exception":"[object] (ErrorException(code: 0): foreach() argument must be of type array|object, string given at /home/hendri/projects/repoFilamentBug/vendor/filament/forms/src/Components/BaseFileUpload.php:710)
[stacktrace]
#0 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /home/hendri/projects/repoFilamentBug/vendor/filament/forms/src/Components/BaseFileUpload.php(710): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
#2 /home/hendri/projects/repoFilamentBug/vendor/filament/forms/src/Concerns/SupportsFileUploadFields.php(39): Filament\\Forms\\Components\\BaseFileUpload->getUploadedFiles()
#3 /home/hendri/projects/repoFilamentBug/vendor/filament/forms/src/Concerns/SupportsFileUploadFields.php(47): Filament\\Forms\\ComponentContainer->getUploadedFiles()
#4 /home/hendri/projects/repoFilamentBug/vendor/filament/forms/src/Concerns/SupportsFileUploadFields.php(47): Filament\\Forms\\ComponentContainer->getUploadedFiles()
#5 /home/hendri/projects/repoFilamentBug/vendor/filament/forms/src/Concerns/InteractsWithForms.php(140): Filament\\Forms\\ComponentContainer->getUploadedFiles()
#6 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Filament\\Pages\\BasePage->getFormUploadedFiles()
#7 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#8 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#9 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod()
#10 /home/hendri/projects/repoFilamentBug/vendor/livewire/livewire/src/Wrapped.php(23): Illuminate\\Container\\BoundMethod::call()
#11 /home/hendri/projects/repoFilamentBug/vendor/livewire/livewire/src/Mechanisms/HandleComponents/HandleComponents.php(467): Livewire\\Wrapped->__call()
#12 /home/hendri/projects/repoFilamentBug/vendor/livewire/livewire/src/Mechanisms/HandleComponents/HandleComponents.php(99): Livewire\\Mechanisms\\HandleComponents\\HandleComponents->callMethods()
#13 /home/hendri/projects/repoFilamentBug/vendor/livewire/livewire/src/LivewireManager.php(96): Livewire\\Mechanisms\\HandleComponents\\HandleComponents->update()
#14 /home/hendri/projects/repoFilamentBug/vendor/livewire/livewire/src/Mechanisms/HandleRequests/HandleRequests.php(89): Livewire\\LivewireManager->update()
#15 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(46): Livewire\\Mechanisms\\HandleRequests\\HandleRequests->handleUpdate()
#16 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Routing/Route.php(260): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#17 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Routing/Route.php(206): Illuminate\\Routing\\Route->runController()
#18 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Routing/Router.php(806): Illuminate\\Routing\\Route->run()
#19 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#20 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#22 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#23 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#24 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#25 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#26 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#27 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#28 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Session\\Middleware\\StartSession->handle()
#29 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#30 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#31 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#32 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#33 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#34 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Routing/Router.php(805): Illuminate\\Pipeline\\Pipeline->then()
#35 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Routing/Router.php(784): Illuminate\\Routing\\Router->runRouteWithinStack()
#36 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Routing/Router.php(748): Illuminate\\Routing\\Router->runRoute()
#37 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Routing/Router.php(737): Illuminate\\Routing\\Router->dispatchToRoute()
#38 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#39 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#40 /home/hendri/projects/repoFilamentBug/vendor/livewire/livewire/src/Features/SupportDisablingBackButtonCache/DisableBackButtonCacheMiddleware.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#41 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Livewire\\Features\\SupportDisablingBackButtonCache\\DisableBackButtonCacheMiddleware->handle()
#42 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#43 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#44 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(46): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#45 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#46 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#47 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()
#48 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#49 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#50 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#51 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\HandleCors->handle()
#52 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#53 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#54 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#55 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#56 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#57 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1168): Illuminate\\Foundation\\Http\\Kernel->handle()
#58 /home/hendri/projects/repoFilamentBug/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()
#59 /home/hendri/projects/repoFilamentBug/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php(16): require_once('...')
#60 {main}
"}sofian-io
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done