@@ -13,16 +13,16 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | $relation = $this->$method(); |
| 15 | 15 | |
| 16 | - if (! $relation instanceof Relation) { |
|
| 16 | + if (!$relation instanceof Relation) { |
|
| 17 | 17 | throw new LogicException(get_class($this).'::'.$method.' must return a relationship instance.'); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | $results = $this->cache([$method]) |
| 21 | - ->rememberForever(str_slug(get_called_class()) . "-{$method}", function () use ($relation) { |
|
| 21 | + ->rememberForever(str_slug(get_called_class())."-{$method}", function() use ($relation) { |
|
| 22 | 22 | return $relation->getResults(); |
| 23 | 23 | }); |
| 24 | 24 | |
| 25 | - return tap($results, function ($results) use ($method) { |
|
| 25 | + return tap($results, function($results) use ($method) { |
|
| 26 | 26 | $this->setRelation($method, $results); |
| 27 | 27 | }); |
| 28 | 28 | } |
@@ -36,19 +36,19 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | parent::boot(); |
| 38 | 38 | |
| 39 | - static::created(function () { |
|
| 39 | + static::created(function() { |
|
| 40 | 40 | self::flushCache(); |
| 41 | 41 | }); |
| 42 | 42 | |
| 43 | - static::deleted(function () { |
|
| 43 | + static::deleted(function() { |
|
| 44 | 44 | self::flushCache(); |
| 45 | 45 | }); |
| 46 | 46 | |
| 47 | - static::saved(function () { |
|
| 47 | + static::saved(function() { |
|
| 48 | 48 | self::flushCache(); |
| 49 | 49 | }); |
| 50 | 50 | |
| 51 | - static::updated(function () { |
|
| 51 | + static::updated(function() { |
|
| 52 | 52 | self::flushCache(); |
| 53 | 53 | }); |
| 54 | 54 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | factory(Author::class, 10)->create() |
| 17 | 17 | ->each(function($author) { |
| 18 | 18 | factory(Book::class, random_int(2, 10))->make() |
| 19 | - ->each(function ($book) use ($author) { |
|
| 19 | + ->each(function($book) use ($author) { |
|
| 20 | 20 | $book->author()->associate($author); |
| 21 | 21 | $book->save(); |
| 22 | 22 | }); |
@@ -7,11 +7,11 @@ |
||
| 7 | 7 | { |
| 8 | 8 | public function createApplication() |
| 9 | 9 | { |
| 10 | - $app = require __DIR__ . '/../vendor/laravel/laravel/bootstrap/app.php'; |
|
| 10 | + $app = require __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php'; |
|
| 11 | 11 | $app->make(Kernel::class)->bootstrap(); |
| 12 | - $app->make(Factory::class)->load(__DIR__ . '/database/factories'); |
|
| 13 | - $app->afterResolving('migrator', function ($migrator) { |
|
| 14 | - $migrator->path(__DIR__ . '/database/migrations'); |
|
| 12 | + $app->make(Factory::class)->load(__DIR__.'/database/factories'); |
|
| 13 | + $app->afterResolving('migrator', function($migrator) { |
|
| 14 | + $migrator->path(__DIR__.'/database/migrations'); |
|
| 15 | 15 | }); |
| 16 | 16 | |
| 17 | 17 | return $app; |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | { |
| 8 | 8 | public function up() |
| 9 | 9 | { |
| 10 | - Schema::create('books', function (Blueprint $table) { |
|
| 10 | + Schema::create('books', 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('authors', function (Blueprint $table) { |
|
| 10 | + Schema::create('authors', 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\Book; |
| 5 | 5 | |
| 6 | -$factory->define(Book::class, function (Faker $faker) { |
|
| 6 | +$factory->define(Book::class, function(Faker $faker) { |
|
| 7 | 7 | return [ |
| 8 | 8 | 'title' => $faker->title, |
| 9 | 9 | 'description' => $faker->paragraphs(3, true), |
@@ -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, |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | $results = $cache |
| 24 | - ->rememberForever("{$parentName}_{$parentIds}-{$childName}s", function () use ($relation) { |
|
| 24 | + ->rememberForever("{$parentName}_{$parentIds}-{$childName}s", function() use ($relation) { |
|
| 25 | 25 | return $relation->getEager(); |
| 26 | 26 | }); |
| 27 | 27 | |