blessing-skin-server/app/Providers/ViewServiceProvider.php

92 lines
2.9 KiB
PHP
Raw Normal View History

2019-09-17 23:10:44 +08:00
<?php
namespace App\Providers;
use App\Http\View\Composers;
2019-12-14 11:10:37 +08:00
use App\Services\Webpack;
2019-09-17 23:10:44 +08:00
use Illuminate\Support\ServiceProvider;
2019-12-14 11:10:37 +08:00
use View;
2019-09-17 23:10:44 +08:00
class ViewServiceProvider extends ServiceProvider
{
2019-09-19 22:13:25 +08:00
public function boot(Webpack $webpack)
2019-09-17 23:10:44 +08:00
{
2019-12-07 16:39:04 +08:00
View::composer([
'home',
'*.base',
'*.master',
2019-12-14 11:10:37 +08:00
'shared.header',
2019-12-07 16:39:04 +08:00
], function ($view) {
2019-12-04 16:45:09 +08:00
$lightColors = ['light', 'warning', 'white', 'orange'];
$color = option('navbar_color');
2019-09-17 23:10:44 +08:00
$view->with([
'site_name' => option_localized('site_name'),
2019-12-04 16:45:09 +08:00
'navbar_color' => $color,
'color_mode' => in_array($color, $lightColors) ? 'light' : 'dark',
2019-09-17 23:10:44 +08:00
]);
});
View::composer('shared.head', Composers\HeadComposer::class);
View::composer('shared.notifications', function ($view) {
$notifications = auth()->user()->unreadNotifications;
$view->with([
'notifications' => $notifications,
'amount' => count($notifications),
]);
});
View::composer('shared.languages', Composers\LanguagesMenuComposer::class);
View::composer('shared.user-menu', Composers\UserMenuComposer::class);
2019-12-04 16:45:09 +08:00
View::composer('shared.sidebar', function ($view) {
$view->with('sidebar_color', option('sidebar_color'));
});
2019-09-17 23:10:44 +08:00
View::composer('shared.side-menu', Composers\SideMenuComposer::class);
View::composer('shared.user-panel', Composers\UserPanelComposer::class);
2019-09-18 23:06:48 +08:00
View::composer('shared.copyright', function ($view) {
2019-09-17 23:10:44 +08:00
$customCopyright = get_string_replaced(
option_localized('copyright_text'),
[
'{site_name}' => option_localized('site_name'),
'{site_url}' => option('site_url'),
]
);
$view->with([
'copyright' => option_localized('copyright_prefer', 0),
'custom_copyright' => $customCopyright,
]);
});
View::composer('shared.foot', Composers\FootComposer::class);
2019-09-18 23:06:48 +08:00
View::composer('auth.*', function ($view) {
$view->with('enable_recaptcha', (bool) option('recaptcha_sitekey'));
$view->with(
'recaptcha_url',
'https://www.recaptcha.net/recaptcha/api.js'
.'?onload=vueRecaptchaApiLoaded&render=explicit'
);
});
2019-09-19 22:13:25 +08:00
View::composer(['errors.*', 'setup.*'], function ($view) use ($webpack) {
$view->with([
'styles' => [
$webpack->url('setup.css'),
],
'scripts' => [
$webpack->url('language-chooser.js'),
],
]);
});
2019-12-15 11:19:10 +08:00
View::composer('auth.oauth', function ($view) {
$view->with('providers', resolve('oauth.providers'));
});
2019-09-17 23:10:44 +08:00
}
}