F
Filament16mo ago
Mis Tsu

Change admin panel logo with spatie-setting package

how to change admin panel logo with spatie-setting value
26 Replies
toeknee
toeknee16mo ago
Call the settings logo where the logo is and change it?
jay02k
jay02k11mo ago
how we exactly do it?
Tieme
Tieme11mo ago
use a uploadfield in your settings something like this
Forms\Components\FileUpload::make('logo')
->image()
->imagePreviewHeight('250')
->panelLayout('integrated')
->previewable(true)
->getUploadedFileNameForStorageUsing(
fn (TemporaryUploadedFile $file): string => (string) str('CompanySettingsLogo.'.$file->guessExtension()),
),
Forms\Components\FileUpload::make('logo')
->image()
->imagePreviewHeight('250')
->panelLayout('integrated')
->previewable(true)
->getUploadedFileNameForStorageUsing(
fn (TemporaryUploadedFile $file): string => (string) str('CompanySettingsLogo.'.$file->guessExtension()),
),
and you can use this in a the logo blade file something like this
<img src="{{ app(CompanySettings::class)->logo }}" alt="Company Logo" >
<img src="{{ app(CompanySettings::class)->logo }}" alt="Company Logo" >
jay02k
jay02k11mo ago
may i know where this image logo save?
jay02k
jay02k11mo ago
i will check and test it thank you I already test it using the code you provide but still keep loading when i click Save changes the loading don't stop, but when i check the storage/app/public the logo is save there FileUpload::make('logo') ->image() ->imagePreviewHeight('72') ->panelLayout('integrated') ->previewable(true) ->getUploadedFileNameForStorageUsing( fn (TemporaryUploadedFile $file): string => (string) str('CompanySettingsLogo.'.$file->guessExtension()) ), it create this file CompanySettingsLogo.png
Tieme
Tieme11mo ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
jay02k
jay02k11mo ago
i will check it thank you btw how exactly i will use this to display the image <img src="{{ app(CompanySettings::class)->logo }}" alt="Company Logo" > i have error
Tieme
Tieme11mo ago
GitHub
GitHub - spatie/laravel-settings: Store strongly typed application ...
Store strongly typed application settings. Contribute to spatie/laravel-settings development by creating an account on GitHub.
jay02k
jay02k11mo ago
i will check it thank you just curious is Spartie Settings plugin really work? I try to follow the docs using the controller but it's not working i got this error even i already use the controller from docs Error: Undefined variable $site_name class GeneralSettingsController { public function show(GeneralSettings $settings){ return view('settings.show', [ 'site_name' => $settings->site_name, 'site_active' => $settings->site_active
]); } I even try this controller class IndexController { public function __invoke(GeneralSettings $settings){ return view('index', [ 'site_name' => $settings->site_name, ]); } }
Tieme
Tieme11mo ago
Have you created migrations, and correctly followd the steps to install and use this package?
jay02k
jay02k11mo ago
yes i am my i only issue is showing the data on the view page like welcome page title
Tieme
Tieme11mo ago
@jay02k Can you share the settings class and the settings.php config file
jay02k
jay02k11mo ago
<?php namespace App\Settings; use Spatie\LaravelSettings\Settings; class AdminSettings extends Settings { public string $site_name; public bool $site_active; public string $site_copyright; public string $site_logo; public string $site_favicon; public static function group(): string { return 'admin'; } }
Tieme
Tieme11mo ago
This wont work if you have AdminSettings and not GeneralSettings
jay02k
jay02k11mo ago
the code i send is already modified with admin this is my new controller <?php namespace App\Http\Controllers; use App\Settings\AdminSettings; use Illuminate\Http\Request; class SettingsController extends Controller { public function show(AdminSettings $settings){ return view('welcome', [ 'site_name' => $settings->site_name ]); } } this is where i want to display it on welcome page <title> {{ $site_name }} </title>
Tieme
Tieme11mo ago
and your settings.php config file?
jay02k
jay02k11mo ago
Tieme
Tieme11mo ago
Are the values stored in the database?
jay02k
jay02k11mo ago
yes all are good it save on the settings page and database
Tieme
Tieme11mo ago
Can you check if this works
class SettingsController extends Controller
{
public function show(){
return view('welcome', [
'site_name' => app(AdminSettings::class)->site_name;
]);
}
}
class SettingsController extends Controller
{
public function show(){
return view('welcome', [
'site_name' => app(AdminSettings::class)->site_name;
]);
}
}
jay02k
jay02k11mo ago
ok still same error Undefined variable $site_name
Tieme
Tieme11mo ago
Can you share the Github Repo please?
jay02k
jay02k11mo ago
its private about that image preview is that a bugs? because i make it a preview ->previewable(true) but the image not showing?
Tieme
Tieme11mo ago
I have send you a PM.
Want results from more Discord servers?
Add your server