42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
// One-time self-healing sync of blog seed content when missing
|
|
try {
|
|
if (\Illuminate\Support\Facades\Schema::hasTable('posts')) {
|
|
$hasGitPost = \Illuminate\Support\Facades\DB::table('posts')
|
|
->where('slug', 'git-mental-model-and-battle-tested-habits-fa')
|
|
->exists();
|
|
if (!$hasGitPost) {
|
|
\Illuminate\Support\Facades\Artisan::call('db:seed', [
|
|
'--class' => 'Database\\Seeders\\Blog\\RealBlogContentSeeder',
|
|
'--force' => true,
|
|
]);
|
|
\Illuminate\Support\Facades\Cache::flush();
|
|
}
|
|
}
|
|
} catch (\Throwable $e) {
|
|
// Silently fall through if DB or migration is in flux
|
|
}
|
|
}
|
|
|
|
}
|