chore: code refactor via rector

This commit is contained in:
idevakk
2025-11-14 02:01:01 -08:00
parent 90ab79b3a2
commit ae795880ed
148 changed files with 1520 additions and 1486 deletions

View File

@@ -2,10 +2,10 @@
namespace App\Providers;
use Illuminate\Support\Facades\DB;
use App\Models\Blog;
use App\Models\Menu;
use App\Models\Plan;
use DB;
use Exception;
use Illuminate\Support\ServiceProvider;
use Laravel\Cashier\Cashier;
@@ -39,27 +39,19 @@ class AppServiceProvider extends ServiceProvider
private function loadApplicationData(): void
{
try {
$settings = cache()->remember('app_settings', now()->addHours(6), function () {
return (array) DB::table('settings')->find(1);
});
$settings = cache()->remember('app_settings', now()->addHours(6), fn(): array => (array) DB::table('settings')->find(1));
$menus = cache()->remember('app_menus', now()->addHours(6), function () {
return Menu::all();
});
$menus = cache()->remember('app_menus', now()->addHours(6), Menu::all(...));
$blogs = cache()->remember('app_blogs', now()->addHours(6), function () {
return Blog::where('is_published', 1)->get();
});
$blogs = cache()->remember('app_blogs', now()->addHours(6), fn() => Blog::query()->where('is_published', 1)->get());
$plans = cache()->remember('app_plans', now()->addHours(6), function () {
return Plan::all();
});
$plans = cache()->remember('app_plans', now()->addHours(6), Plan::all(...));
config(['app.settings' => (array) $settings]);
config(['app.menus' => $menus]);
config(['app.blogs' => $blogs]);
config(['app.plans' => $plans]);
} catch (Exception $e) {
} catch (Exception) {
// Fail silently if database is not available
// This allows the application to boot during migrations and testing
}