mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-09 20:19:26 +01:00
allow app icon to be used instead of a third party service
This commit is contained in:
parent
49f24e37b6
commit
a725029e37
25
app/AvatarProviders/PelicanAvatarProvider.php
Normal file
25
app/AvatarProviders/PelicanAvatarProvider.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\AvatarProviders;
|
||||||
|
|
||||||
|
use Filament\AvatarProviders\Contracts\AvatarProvider;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class PelicanAvatarProvider implements AvatarProvider
|
||||||
|
{
|
||||||
|
public function get(Model|Authenticatable $record): string
|
||||||
|
{
|
||||||
|
$logo = config('app.logo');
|
||||||
|
|
||||||
|
if (filled($logo)) {
|
||||||
|
if (str_starts_with($logo, 'http://') || str_starts_with($logo, 'https://')) {
|
||||||
|
return $logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url($logo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return url('/pelican.svg');
|
||||||
|
}
|
||||||
|
}
|
||||||
34
app/Extensions/Avatar/Schemas/AppLogoSchema.php
Normal file
34
app/Extensions/Avatar/Schemas/AppLogoSchema.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Extensions\Avatar\Schemas;
|
||||||
|
|
||||||
|
use App\Extensions\Avatar\AvatarSchemaInterface;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class AppLogoSchema implements AvatarSchemaInterface
|
||||||
|
{
|
||||||
|
public function getId(): string
|
||||||
|
{
|
||||||
|
return 'appIcon';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): string
|
||||||
|
{
|
||||||
|
return 'App Icon';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(User $user): string
|
||||||
|
{
|
||||||
|
$logo = config('app.logo');
|
||||||
|
|
||||||
|
if (filled($logo)) {
|
||||||
|
if (str_starts_with($logo, 'http://') || str_starts_with($logo, 'https://')) {
|
||||||
|
return $logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url($logo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '/pelican.svg';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Providers\Extensions;
|
namespace App\Providers\Extensions;
|
||||||
|
|
||||||
use App\Extensions\Avatar\AvatarService;
|
use App\Extensions\Avatar\AvatarService;
|
||||||
|
use App\Extensions\Avatar\Schemas\AppLogoSchema;
|
||||||
use App\Extensions\Avatar\Schemas\GravatarSchema;
|
use App\Extensions\Avatar\Schemas\GravatarSchema;
|
||||||
use App\Extensions\Avatar\Schemas\UiAvatarsSchema;
|
use App\Extensions\Avatar\Schemas\UiAvatarsSchema;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
@ -17,6 +18,7 @@ class AvatarServiceProvider extends ServiceProvider
|
|||||||
// Default Avatar providers
|
// Default Avatar providers
|
||||||
$service->register(new GravatarSchema());
|
$service->register(new GravatarSchema());
|
||||||
$service->register(new UiAvatarsSchema());
|
$service->register(new UiAvatarsSchema());
|
||||||
|
$service->register(new AppLogoSchema());
|
||||||
|
|
||||||
return $service;
|
return $service;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Providers\Filament;
|
namespace App\Providers\Filament;
|
||||||
|
|
||||||
|
use App\AvatarProviders\PelicanAvatarProvider;
|
||||||
use App\Enums\CustomizationKey;
|
use App\Enums\CustomizationKey;
|
||||||
use App\Filament\Pages\Auth\EditProfile;
|
use App\Filament\Pages\Auth\EditProfile;
|
||||||
use App\Filament\Pages\Auth\Login;
|
use App\Filament\Pages\Auth\Login;
|
||||||
@ -34,6 +35,7 @@ abstract class PanelProvider extends BasePanelProvider
|
|||||||
->brandLogo(config('app.logo'))
|
->brandLogo(config('app.logo'))
|
||||||
->brandLogoHeight('2rem')
|
->brandLogoHeight('2rem')
|
||||||
->favicon(config('app.favicon', '/pelican.ico'))
|
->favicon(config('app.favicon', '/pelican.ico'))
|
||||||
|
->defaultAvatarProvider(PelicanAvatarProvider::class)
|
||||||
->topNavigation(function () {
|
->topNavigation(function () {
|
||||||
$navigationType = user()?->getCustomization(CustomizationKey::TopNavigation);
|
$navigationType = user()?->getCustomization(CustomizationKey::TopNavigation);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user