Skip to content
This repository has been archived by the owner on Apr 18, 2020. It is now read-only.

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
Sparclex authored and StyleCIBot committed Nov 23, 2018
1 parent d847aea commit f7abc2b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
14 changes: 8 additions & 6 deletions src/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,21 @@ public function handle(NovaRequest $request)
protected function extractValidationRules($request, $resource)
{
return collect($resource::rulesForCreation($request))->mapWithKeys(function ($rule, $key) {
foreach($rule as $i => $r)
{
if(!is_object($r)) continue;
foreach ($rule as $i => $r) {
if (! is_object($r)) {
continue;
}

// Make sure relation checks start out with a clean query
if(is_a($r, Relatable::class))
{
$rule[$i] = function() use($r) {
if (is_a($r, Relatable::class)) {
$rule[$i] = function () use ($r) {
$r->query = $r->query->newQuery();

return $r;
};
}
}

return [$key => $rule];
});
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Factories/AddressFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
use Sparclex\NovaImportCard\Tests\Fixtures\User;
use Sparclex\NovaImportCard\Tests\Fixtures\Address;


$factory->define(Address::class, function (Faker $faker) {
return [
'user_id' => function() {
'user_id' => function () {
return factory(User::class)->create()->id;
},
'street' => $faker->word,
Expand Down
4 changes: 1 addition & 3 deletions tests/Feature/ImportCsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
use Illuminate\Http\Testing\File;
use Illuminate\Support\Facades\Storage;
use Sparclex\NovaImportCard\Tests\Fixtures\User;
use Sparclex\NovaImportCard\Tests\Fixtures\Entry;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Sparclex\NovaImportCard\Tests\IntegrationTest;
use Sparclex\NovaImportCard\Tests\Fixtures\Address;

class ImportCsvTest extends IntegrationTest
{
Expand Down Expand Up @@ -105,7 +103,7 @@ public function it_should_import_with_related()
]);
}

/** @test */
/** @test */
public function it_should_import_with_nullable_related()
{
$this->authenticate();
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/AddressResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function fields(Request $request)
return [
ID::make('ID', 'id'),
BelongsTo::make('User', 'user', UserResource::class)->nullable(),
Text::make('Street')
Text::make('Street'),
];
}
}
2 changes: 1 addition & 1 deletion tests/Fixtures/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function fields(Request $request)
Text::make('Username')->rules('required'),
Text::make('Name')->rules('required'),
Text::make('Age')->rules('nullable', 'numeric'),
HasOne::make('Address', 'address', AddressResource::class)
HasOne::make('Address', 'address', AddressResource::class),
];
}
}
2 changes: 1 addition & 1 deletion tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function setUp()

Nova::resources([
UserResource::class,
AddressResource::class
AddressResource::class,
]);

Nova::auth(function () {
Expand Down

0 comments on commit f7abc2b

Please sign in to comment.