@@ -3,7 +3,7 @@ |
||
3 | 3 | use Faker\Generator as Faker; |
4 | 4 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author; |
5 | 5 | |
6 | -$factory->define(Author::class, function (Faker $faker) { |
|
6 | +$factory->define(Author::class, function(Faker $faker) { |
|
7 | 7 | return [ |
8 | 8 | 'name' => $faker->name, |
9 | 9 | 'email' => $faker->unique()->safeEmail, |
@@ -7,7 +7,7 @@ |
||
7 | 7 | { |
8 | 8 | public function up() |
9 | 9 | { |
10 | - Schema::create('book_store', function (Blueprint $table) { |
|
10 | + Schema::create('book_store', function(Blueprint $table) { |
|
11 | 11 | $table->increments('id'); |
12 | 12 | $table->unsignedInteger('book_id'); |
13 | 13 | $table->unsignedInteger('store_id'); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | { |
8 | 8 | public function up() |
9 | 9 | { |
10 | - Schema::create('profiles', function (Blueprint $table) { |
|
10 | + Schema::create('profiles', function(Blueprint $table) { |
|
11 | 11 | $table->increments('id'); |
12 | 12 | $table->unsignedInteger('author_id'); |
13 | 13 | $table->timestamps(); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | { |
8 | 8 | public function up() |
9 | 9 | { |
10 | - Schema::create('stores', function (Blueprint $table) { |
|
10 | + Schema::create('stores', function(Blueprint $table) { |
|
11 | 11 | $table->increments('id'); |
12 | 12 | $table->timestamps(); |
13 | 13 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | use Faker\Generator as Faker; |
4 | 4 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Store; |
5 | 5 | |
6 | -$factory->define(Store::class, function (Faker $faker) { |
|
6 | +$factory->define(Store::class, function(Faker $faker) { |
|
7 | 7 | return [ |
8 | 8 | 'address' => $faker->address, |
9 | 9 | 'name' => $faker->company, |
@@ -6,7 +6,7 @@ |
||
6 | 6 | { |
7 | 7 | public function all($columns = ['*']) : Collection |
8 | 8 | { |
9 | - if (! $this->isCachable()) { |
|
9 | + if (!$this->isCachable()) { |
|
10 | 10 | $this->model->disableModelCaching(); |
11 | 11 | } |
12 | 12 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | { |
13 | 13 | $option = $this->option('model'); |
14 | 14 | |
15 | - if (! $option) { |
|
15 | + if (!$option) { |
|
16 | 16 | return $this->flushEntireCache(); |
17 | 17 | } |
18 | 18 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $usesCachableTrait = $this->getAllTraitsUsedByClass($option) |
37 | 37 | ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable"); |
38 | 38 | |
39 | - if (! $usesCachableTrait) { |
|
39 | + if (!$usesCachableTrait) { |
|
40 | 40 | $this->error("'{$option}' is not an instance of CachedModel."); |
41 | 41 | $this->line("Only CachedModel instances can be flushed."); |
42 | 42 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | { |
29 | 29 | $tags = collect($this->eagerLoad) |
30 | 30 | ->keys() |
31 | - ->map(function ($relationName) { |
|
31 | + ->map(function($relationName) { |
|
32 | 32 | $relation = $this->getRelation($relationName); |
33 | 33 | |
34 | 34 | return $this->getCachePrefix() |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | protected function getRelation(string $relationName) : Relation |
54 | 54 | { |
55 | 55 | return collect(explode('.', $relationName)) |
56 | - ->reduce(function ($carry, $name) { |
|
56 | + ->reduce(function($carry, $name) { |
|
57 | 57 | $carry = $carry ?: $this->model; |
58 | 58 | $carry = $this->getRelatedModel($carry); |
59 | 59 |
@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | $key = $instance->makeCacheKey(); |
23 | 23 | |
24 | 24 | return $instance->cache($tags) |
25 | - ->rememberForever($key, function () use ($columns) { |
|
25 | + ->rememberForever($key, function() use ($columns) { |
|
26 | 26 | return parent::all($columns); |
27 | 27 | }); |
28 | 28 | } |
29 | 29 | |
30 | 30 | public static function bootCachable() |
31 | 31 | { |
32 | - static::created(function ($instance) { |
|
32 | + static::created(function($instance) { |
|
33 | 33 | $instance->checkCooldownAndFlushAfterPersisting($instance); |
34 | 34 | }); |
35 | 35 | |
36 | - static::deleted(function ($instance) { |
|
36 | + static::deleted(function($instance) { |
|
37 | 37 | $instance->checkCooldownAndFlushAfterPersisting($instance); |
38 | 38 | }); |
39 | 39 | |
40 | - static::saved(function ($instance) { |
|
40 | + static::saved(function($instance) { |
|
41 | 41 | $instance->checkCooldownAndFlushAfterPersisting($instance); |
42 | 42 | }); |
43 | 43 | |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | // $instance->checkCooldownAndFlushAfterPersisting($instance); |
47 | 47 | // }); |
48 | 48 | |
49 | - static::pivotAttached(function ($instance, $secondInstance, $relationship) { |
|
49 | + static::pivotAttached(function($instance, $secondInstance, $relationship) { |
|
50 | 50 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
51 | 51 | }); |
52 | 52 | |
53 | - static::pivotDetached(function ($instance, $secondInstance, $relationship) { |
|
53 | + static::pivotDetached(function($instance, $secondInstance, $relationship) { |
|
54 | 54 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
55 | 55 | }); |
56 | 56 | |
57 | - static::pivotUpdated(function ($instance, $secondInstance, $relationship) { |
|
57 | + static::pivotUpdated(function($instance, $secondInstance, $relationship) { |
|
58 | 58 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
59 | 59 | }); |
60 | 60 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | public function newEloquentBuilder($query) |
72 | 72 | { |
73 | - if (! $this->isCachable()) { |
|
73 | + if (!$this->isCachable()) { |
|
74 | 74 | $this->isCachable = false; |
75 | 75 | |
76 | 76 | return new EloquentBuilder($query); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | EloquentBuilder $query, |
115 | 115 | int $seconds = null |
116 | 116 | ) : EloquentBuilder { |
117 | - if (! $seconds) { |
|
117 | + if (!$seconds) { |
|
118 | 118 | $seconds = $this->cacheCooldownSeconds; |
119 | 119 | } |
120 | 120 | |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds"; |
124 | 124 | |
125 | 125 | $this->cache() |
126 | - ->rememberForever($cacheKey, function () use ($seconds) { |
|
126 | + ->rememberForever($cacheKey, function() use ($seconds) { |
|
127 | 127 | return $seconds; |
128 | 128 | }); |
129 | 129 | |
130 | 130 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at"; |
131 | 131 | $this->cache() |
132 | - ->rememberForever($cacheKey, function () { |
|
132 | + ->rememberForever($cacheKey, function() { |
|
133 | 133 | return (new Carbon)->now(); |
134 | 134 | }); |
135 | 135 |
@@ -43,9 +43,9 @@ |
||
43 | 43 | $class = get_called_class(); |
44 | 44 | $instance = new $class; |
45 | 45 | |
46 | - if (!$instance->isCachable()) { |
|
47 | - return parent::all($columns); |
|
48 | - } |
|
46 | + if (!$instance->isCachable()) { |
|
47 | + return parent::all($columns); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | $tags = $instance->makeCacheTags(); |
51 | 51 | $key = $instance->makeCacheKey(); |