42 lines
899 B
PHP
42 lines
899 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Blog;
|
|
use App\Models\Menu;
|
|
use DB;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
$settings = cache()->remember('app_settings', now()->addSecond(1), function () {
|
|
return (array) DB::table('settings')->find(1);
|
|
});
|
|
$menus = Menu::all();
|
|
$blogs = Blog::where(['is_published' => 1])->get();
|
|
if ($settings) {
|
|
config(['app.settings' => (array) $settings]);
|
|
}
|
|
if ($menus) {
|
|
config(['app.menus' => $menus]);
|
|
}
|
|
if ($blogs) {
|
|
config(['app.blogs' => $blogs]);
|
|
}
|
|
|
|
}
|
|
}
|