2019-09-17 23:10:44 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
|
|
use View;
|
|
|
|
use App\Http\View\Composers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class ViewServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
public function boot()
|
|
|
|
{
|
2019-09-18 23:06:48 +08:00
|
|
|
View::composer(['home', '*.base', 'shared.header'], function ($view) {
|
2019-09-17 23:10:44 +08:00
|
|
|
$view->with([
|
|
|
|
'site_name' => option_localized('site_name'),
|
|
|
|
'color_scheme' => option('color_scheme'),
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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-17 23:10:44 +08:00
|
|
|
}
|
|
|
|
}
|