@@ -34,18 +34,18 @@ discard block |
||
34 | 34 | |
35 | 35 | protected function applyScopesToInstance() |
36 | 36 | { |
37 | - if (! property_exists($this, "scopes") |
|
37 | + if (!property_exists($this, "scopes") |
|
38 | 38 | || $this->scopesAreApplied |
39 | 39 | ) { |
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | 43 | foreach ($this->scopes as $identifier => $scope) { |
44 | - if (! isset($this->scopes[$identifier])) { |
|
44 | + if (!isset($this->scopes[$identifier])) { |
|
45 | 45 | continue; |
46 | 46 | } |
47 | 47 | |
48 | - $this->callScope(function () use ($scope) { |
|
48 | + $this->callScope(function() use ($scope) { |
|
49 | 49 | if ($scope instanceof Closure) { |
50 | 50 | $scope($this); |
51 | 51 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
104 | 104 | |
105 | 105 | $this->cache() |
106 | - ->rememberForever($cacheKey, function () { |
|
106 | + ->rememberForever($cacheKey, function() { |
|
107 | 107 | return (new Carbon)->now(); |
108 | 108 | }); |
109 | 109 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | public function getModelCacheCooldown(Model $instance) : array |
182 | 182 | { |
183 | - if (! $instance->cacheCooldownSeconds) { |
|
183 | + if (!$instance->cacheCooldownSeconds) { |
|
184 | 184 | return [null, null, null]; |
185 | 185 | } |
186 | 186 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | [$cacheCooldown, $invalidatedAt, $savedAt] = $this |
190 | 190 | ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName); |
191 | 191 | |
192 | - if (! $cacheCooldown || $cacheCooldown === 0) { |
|
192 | + if (!$cacheCooldown || $cacheCooldown === 0) { |
|
193 | 193 | return [null, null, null]; |
194 | 194 | } |
195 | 195 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | { |
219 | 219 | [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance); |
220 | 220 | |
221 | - if (! $cacheCooldown |
|
221 | + if (!$cacheCooldown |
|
222 | 222 | || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown |
223 | 223 | ) { |
224 | 224 | return; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | { |
244 | 244 | [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance); |
245 | 245 | |
246 | - if (! $cacheCooldown) { |
|
246 | + if (!$cacheCooldown) { |
|
247 | 247 | $instance->flushCache(); |
248 | 248 | |
249 | 249 | if ($relationship) { |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | public function isCachable() : bool |
272 | 272 | { |
273 | - $isCacheDisabled = ! Container::getInstance() |
|
273 | + $isCacheDisabled = !Container::getInstance() |
|
274 | 274 | ->make("config") |
275 | 275 | ->get("laravel-model-caching.enabled"); |
276 | 276 | $allRelationshipsAreCachable = true; |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | $allRelationshipsAreCachable = collect($this |
282 | 282 | ->eagerLoad) |
283 | 283 | ->keys() |
284 | - ->reduce(function ($carry, $related) { |
|
285 | - if (! method_exists($this, $related) |
|
284 | + ->reduce(function($carry, $related) { |
|
285 | + if (!method_exists($this, $related) |
|
286 | 286 | || $carry === false |
287 | 287 | ) { |
288 | 288 | return $carry; |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | |
291 | 291 | $relatedModel = $this->model->$related()->getRelated(); |
292 | 292 | |
293 | - if (! method_exists($relatedModel, "isCachable") |
|
294 | - || ! $relatedModel->isCachable() |
|
293 | + if (!method_exists($relatedModel, "isCachable") |
|
294 | + || !$relatedModel->isCachable() |
|
295 | 295 | ) { |
296 | 296 | return false; |
297 | 297 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | } |
303 | 303 | |
304 | 304 | return $this->isCachable |
305 | - && ! $isCacheDisabled |
|
305 | + && !$isCacheDisabled |
|
306 | 306 | && $allRelationshipsAreCachable; |
307 | 307 | } |
308 | 308 | |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
314 | 314 | |
315 | 315 | $instance->cache() |
316 | - ->rememberForever($cacheKey, function () { |
|
316 | + ->rememberForever($cacheKey, function() { |
|
317 | 317 | return (new Carbon)->now(); |
318 | 318 | }); |
319 | 319 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | public function boot() |
16 | 16 | { |
17 | - $configPath = __DIR__ . '/../../config/laravel-model-caching.php'; |
|
17 | + $configPath = __DIR__.'/../../config/laravel-model-caching.php'; |
|
18 | 18 | $this->mergeConfigFrom($configPath, 'laravel-model-caching'); |
19 | 19 | $this->commands([ |
20 | 20 | Clear::class, |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public function register() |
29 | 29 | { |
30 | - if (! class_exists('GeneaLabs\LaravelModelCaching\EloquentBuilder')) { |
|
30 | + if (!class_exists('GeneaLabs\LaravelModelCaching\EloquentBuilder')) { |
|
31 | 31 | class_alias( |
32 | 32 | ModelCaching::builder(), |
33 | 33 | 'GeneaLabs\LaravelModelCaching\EloquentBuilder' |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $beforeBook->title = 'new foo'; |
16 | 16 | $beforeBook->save(); |
17 | 17 | |
18 | - $this->postJson('nova-api/books/' . $beforeBook->id . '/attach/stores' , [ |
|
18 | + $this->postJson('nova-api/books/'.$beforeBook->id.'/attach/stores', [ |
|
19 | 19 | 'stores' => $beforeStore->id, |
20 | 20 | 'viaRelationship' => 'stores' |
21 | 21 | ]); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $beforeBooks = $beforeStore->books; |
48 | 48 | $beforeBook = $beforeBooks->first(); |
49 | 49 | |
50 | - $this->deleteJson('/nova-api/stores/detach?viaResource=books&viaResourceId=' . $beforeBook->id . '&viaRelationship=stores' , [ |
|
50 | + $this->deleteJson('/nova-api/stores/detach?viaResource=books&viaResourceId='.$beforeBook->id.'&viaRelationship=stores', [ |
|
51 | 51 | 'resources' => [$beforeStore->id], |
52 | 52 | ]); |
53 | 53 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $beforeStore = Store::with(['books'])->get()->first(); |
67 | 67 | $beforeBook = $beforeStore->books->first(); |
68 | 68 | |
69 | - $this->putJson('nova-api/books/' . $beforeBook->id, [ |
|
69 | + $this->putJson('nova-api/books/'.$beforeBook->id, [ |
|
70 | 70 | 'title' => 'foo', |
71 | 71 | ]); |
72 | 72 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | $beforeAuthors = (new Author)->get(); |
11 | 11 | $author = $beforeAuthors->first(); |
12 | 12 | |
13 | - $this->putJson('nova-api/authors/' . $author->id, [ |
|
13 | + $this->putJson('nova-api/authors/'.$author->id, [ |
|
14 | 14 | 'name' => 'foo', |
15 | 15 | 'email' => '[email protected]', |
16 | 16 | ]); |
@@ -31,20 +31,20 @@ discard block |
||
31 | 31 | |
32 | 32 | $this->setUpBaseLineSqlLiteDatabase(); |
33 | 33 | |
34 | - $databasePath = __DIR__ . "/database"; |
|
34 | + $databasePath = __DIR__."/database"; |
|
35 | 35 | $this->testingSqlitePath = "{$databasePath}/"; |
36 | 36 | $baselinePath = "{$databasePath}/baseline.sqlite"; |
37 | 37 | $testingPath = "{$databasePath}/testing.sqlite"; |
38 | 38 | |
39 | - ! file_exists($testingPath) |
|
39 | + !file_exists($testingPath) |
|
40 | 40 | ?: unlink($testingPath); |
41 | 41 | copy($baselinePath, $testingPath); |
42 | 42 | |
43 | - require(__DIR__ . '/routes/web.php'); |
|
43 | + require(__DIR__.'/routes/web.php'); |
|
44 | 44 | |
45 | - $this->withFactories(__DIR__ . '/database/factories'); |
|
45 | + $this->withFactories(__DIR__.'/database/factories'); |
|
46 | 46 | |
47 | - view()->addLocation(__DIR__ . '/resources/views', 'laravel-model-caching'); |
|
47 | + view()->addLocation(__DIR__.'/resources/views', 'laravel-model-caching'); |
|
48 | 48 | |
49 | 49 | $this->cache = app('cache') |
50 | 50 | ->store(config('laravel-model-caching.store')); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | self::$baseLineDatabaseMigrated = true; |
71 | 71 | |
72 | - $file = __DIR__ . '/database/baseline.sqlite'; |
|
72 | + $file = __DIR__.'/database/baseline.sqlite'; |
|
73 | 73 | $this->app['config']->set('database.default', 'baseline'); |
74 | 74 | $this->app['config']->set('database.connections.baseline', [ |
75 | 75 | 'driver' => 'sqlite', |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | "foreign_key_constraints" => false, |
80 | 80 | ]); |
81 | 81 | |
82 | - ! file_exists($file) |
|
82 | + !file_exists($file) |
|
83 | 83 | ?: unlink($file); |
84 | 84 | touch($file); |
85 | 85 | |
86 | - $this->withFactories(__DIR__ . '/database/factories'); |
|
87 | - $this->loadMigrationsFrom(__DIR__ . '/database/migrations'); |
|
86 | + $this->withFactories(__DIR__.'/database/factories'); |
|
87 | + $this->loadMigrationsFrom(__DIR__.'/database/migrations'); |
|
88 | 88 | |
89 | 89 | Artisan::call('db:seed', [ |
90 | 90 | '--class' => 'DatabaseSeeder', |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $app['config']->set('database.default', 'testing'); |
100 | 100 | $app['config']->set('database.connections.testing', [ |
101 | 101 | 'driver' => 'sqlite', |
102 | - 'database' => __DIR__ . '/database/testing.sqlite', |
|
102 | + 'database' => __DIR__.'/database/testing.sqlite', |
|
103 | 103 | 'prefix' => '', |
104 | 104 | "foreign_key_constraints" => false, |
105 | 105 | ]); |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | "commentable_id" => $post->id, |
43 | 43 | "commentable_type" => Post::class, |
44 | 44 | ]) |
45 | - ->each(function ($comment) { |
|
45 | + ->each(function($comment) { |
|
46 | 46 | (new Comment)->create([ |
47 | 47 | "commentable_id" => $comment->commentable_id, |
48 | 48 | "commentable_type" => UncachedPost::class, |
49 | 49 | "description" => $comment->description, |
50 | - "subject" => $comment->subject . ' - uncached post', |
|
50 | + "subject" => $comment->subject.' - uncached post', |
|
51 | 51 | ]); |
52 | 52 | }); |
53 | 53 | $publishers = factory(Publisher::class, 10)->create(); |
54 | 54 | (new Author)->observe(AuthorObserver::class); |
55 | 55 | factory(Author::class, 10)->create() |
56 | - ->each(function ($author) use ($publishers) { |
|
56 | + ->each(function($author) use ($publishers) { |
|
57 | 57 | $profile = factory(Profile::class) |
58 | 58 | ->make(); |
59 | 59 | $profile->author_id = $author->id; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | "author_id" => $author->id, |
64 | 64 | "publisher_id" => $publishers[rand(0, 9)]->id, |
65 | 65 | ]) |
66 | - ->each(function ($book) use ($author, $publishers) { |
|
66 | + ->each(function($book) use ($author, $publishers) { |
|
67 | 67 | factory(Printer::class)->create([ |
68 | 68 | "book_id" => $book->id, |
69 | 69 | ]); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $bookIds = (new Book)->all()->pluck('id'); |
77 | 77 | factory(Store::class, 10)->create() |
78 | - ->each(function ($store) use ($bookIds) { |
|
78 | + ->each(function($store) use ($bookIds) { |
|
79 | 79 | $store->books()->sync(rand($bookIds->min(), $bookIds->max())); |
80 | 80 | }); |
81 | 81 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Supplier; |
5 | 5 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\User; |
6 | 6 | |
7 | -$factory->define(User::class, function (Faker $faker) { |
|
7 | +$factory->define(User::class, function(Faker $faker) { |
|
8 | 8 | return [ |
9 | 9 | 'name' => $faker->name, |
10 | 10 | "supplier_id" => factory(Supplier::class)->create()->id, |
@@ -4,7 +4,7 @@ |
||
4 | 4 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\History; |
5 | 5 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\User; |
6 | 6 | |
7 | -$factory->define(History::class, function (Faker $faker) { |
|
7 | +$factory->define(History::class, function(Faker $faker) { |
|
8 | 8 | return [ |
9 | 9 | 'name' => $faker->name, |
10 | 10 | "user_id" => factory(User::class)->create()->id, |
@@ -3,7 +3,7 @@ |
||
3 | 3 | use Faker\Generator as Faker; |
4 | 4 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedAuthor; |
5 | 5 | |
6 | -$factory->define(UncachedAuthor::class, function (Faker $faker) { |
|
6 | +$factory->define(UncachedAuthor::class, function(Faker $faker) { |
|
7 | 7 | return [ |
8 | 8 | 'name' => $faker->name, |
9 | 9 | 'email' => $faker->unique()->safeEmail, |