Skip to content

Commit

Permalink
Fix error during artisan package:discover
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyiliev committed Oct 27, 2022
1 parent a23b40c commit 67778d4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ThemesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DevDojo\Themes;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use TCG\Voyager\Models\Menu;
use TCG\Voyager\Models\Role;
use TCG\Voyager\Models\MenuItem;
Expand All @@ -29,7 +30,13 @@ class ThemesServiceProvider extends ServiceProvider
public function register()
{
if ( request()->is(config('voyager.prefix')) || request()->is(config('voyager.prefix').'/*') || app()->runningInConsole() ) {
$this->addThemesTable();

try {
DB::connection()->getPdo();
$this->addThemesTable();
} catch (\Exception $e) {
\Log::error("Error connecting to database: ".$e->getMessage());
}

app(Dispatcher::class)->listen('voyager.menu.display', function ($menu) {
$this->addThemeMenuItem($menu);
Expand Down

0 comments on commit 67778d4

Please sign in to comment.