Skip to content

Commit 6fb6fd9

Browse files
author
Quentin Schmick
authored
Laravel 8 fix (#288)
* Updated registration of console service provider into the register method instead of the boot * Style fixes
1 parent 15dc235 commit 6fb6fd9

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

src/Providers/ConsoleServiceProvider.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\ServiceProvider;
88
use Studio\Totem\Events\Executed;
99
use Studio\Totem\Events\Executing;
10+
use Studio\Totem\Totem;
1011

1112
class ConsoleServiceProvider extends ServiceProvider
1213
{
@@ -17,9 +18,11 @@ class ConsoleServiceProvider extends ServiceProvider
1718
*/
1819
public function boot()
1920
{
20-
$this->app->resolving(Schedule::class, function ($schedule) {
21-
$this->schedule($schedule);
22-
});
21+
if (Totem::baseTableExists()) {
22+
$this->app->resolving(Schedule::class, function ($schedule) {
23+
$this->schedule($schedule);
24+
});
25+
}
2326
}
2427

2528
/**

src/Providers/TotemServiceProvider.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
use Cron\CronExpression;
66
use Illuminate\Http\UploadedFile;
7-
use Illuminate\Support\Facades\Log;
87
use Illuminate\Support\Facades\Schema;
98
use Illuminate\Support\Facades\Validator;
109
use Illuminate\Support\ServiceProvider;
1110
use Studio\Totem\Console\Commands\ListSchedule;
1211
use Studio\Totem\Console\Commands\PublishAssets;
1312
use Studio\Totem\Contracts\TaskInterface;
1413
use Studio\Totem\Repositories\EloquentTaskRepository;
15-
use Studio\Totem\Totem;
1614

1715
class TotemServiceProvider extends ServiceProvider
1816
{
@@ -23,14 +21,6 @@ class TotemServiceProvider extends ServiceProvider
2321
*/
2422
public function boot()
2523
{
26-
try {
27-
if (Totem::baseTableExists()) {
28-
$this->app->register(ConsoleServiceProvider::class);
29-
}
30-
} catch (\PDOException $ex) {
31-
// This will trigger if DB cannot be connected to
32-
Log::error($ex->getMessage());
33-
}
3424
$this->registerResources();
3525
$this->defineAssetPublishing();
3626

@@ -77,6 +67,7 @@ public function register()
7767
$this->app->register(TotemRouteServiceProvider::class);
7868
$this->app->register(TotemEventServiceProvider::class);
7969
$this->app->register(TotemFormServiceProvider::class);
70+
$this->app->register(ConsoleServiceProvider::class);
8071
}
8172

8273
/**

tests/Feature/AuthTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public function auth_middleware_works()
3232
$middleware = new Authenticate;
3333

3434
$response = $middleware->handle(
35-
new class {
35+
new class
36+
{
3637
},
3738
function ($value) {
3839
return 'response';
@@ -55,7 +56,8 @@ public function auth_middleware_responds_with_403_on_failure()
5556
$middleware = new Authenticate;
5657

5758
$response = $middleware->handle(
58-
new class {
59+
new class
60+
{
5961
},
6062
function ($value) {
6163
return 'response';

tests/TestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ protected function getPackageProviders($app)
7474
*/
7575
protected function disableExceptionHandling()
7676
{
77-
$this->app->instance(ExceptionHandler::class, new class() extends Handler {
77+
$this->app->instance(ExceptionHandler::class, new class() extends Handler
78+
{
7879
public function __construct()
7980
{
8081
}

0 commit comments

Comments
 (0)