Skip to content

Commit 6360d00

Browse files
committed
Allow opting out of migrations and queue bindings
1 parent 22bbefd commit 6360d00

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

src/LaravelJsonApi.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace CloudCreativity\LaravelJsonApi;
4+
5+
class LaravelJsonApi
6+
{
7+
8+
/**
9+
* Indicates if Laravel JSON API migrations will be run.
10+
*
11+
* @var bool
12+
*/
13+
public static $runMigrations = true;
14+
15+
/**
16+
* Indicates if listeners will be bound to the Laravel queue events.
17+
*
18+
* @var bool
19+
*/
20+
public static $queueBindings = true;
21+
22+
/**
23+
* @return LaravelJsonApi
24+
*/
25+
public static function ignoreMigrations(): self
26+
{
27+
static::$runMigrations = false;
28+
29+
return new self();
30+
}
31+
32+
/**
33+
* @return LaravelJsonApi
34+
*/
35+
public static function skipQueueBindings(): self
36+
{
37+
static::$queueBindings = false;
38+
39+
return new self();
40+
}
41+
}

src/ServiceProvider.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ public function boot(Router $router)
6969
$this->bootBladeDirectives();
7070
$this->bootTranslations();
7171

72-
Queue::after(UpdateClientProcess::class);
73-
Queue::failing(UpdateClientProcess::class);
72+
if (LaravelJsonApi::$queueBindings) {
73+
Queue::after(UpdateClientProcess::class);
74+
Queue::failing(UpdateClientProcess::class);
75+
}
7476

7577
if ($this->app->runningInConsole()) {
7678
$this->bootMigrations();
@@ -159,7 +161,9 @@ protected function bootBladeDirectives()
159161
*/
160162
protected function bootMigrations()
161163
{
162-
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
164+
if (LaravelJsonApi::$runMigrations) {
165+
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
166+
}
163167
}
164168

165169
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy