Skip to content

Commit

Permalink
Merge pull request simonhamp#23 from ruerdev/master
Browse files Browse the repository at this point in the history
Don't show resources in preview when they don't have a (useful) model
  • Loading branch information
simonhamp authored Mar 3, 2020
2 parents e3daae6 + 7ff6c86 commit 127f94f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Http/Controllers/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Laravel\Nova\Nova;
use Laravel\Nova\Resource;
use Laravel\Nova\Rules\Relatable;
use Laravel\Nova\Actions\ActionResource;
use Laravel\Nova\Http\Requests\NovaRequest;
use SimonHamp\LaravelNovaCsvImport\Importer;
use Illuminate\Validation\ValidationException;
Expand Down Expand Up @@ -39,6 +40,14 @@ public function preview(NovaRequest $request, $file)
$resources = collect(Nova::$resources);

$resources = $resources->filter(function ($resource) {
if ($resource === ActionResource::class) {
return false;
}

if (!isset($resource::$model)) {
return false;
}

$static_vars = (new \ReflectionClass((string) $resource))->getStaticProperties();

if(!isset($static_vars['canImportResource'])) {
Expand Down

0 comments on commit 127f94f

Please sign in to comment.