Sparclex / nova-import-card

A customizable resource import card for laravel nova
MIT License
31 stars 34 forks source link

Class 'App\Providers\App\Nova\User' not found #14

Closed trueman52 closed 5 years ago

trueman52 commented 5 years ago

Returned error: Class 'App\Providers\App\Nova\User' not found

After default Laravel Nova installation Then installing package via composer: "composer require sparclex/nova-import-card"

Then registering in "NovaServiceProvider.php" file

public function card() { return [ // ... new \Sparclex\NovaImportCard\NovaImportCard(App\Nova\User::class), ]; }

Application returned error:

Class 'App\Providers\App\Nova\User' not found

In vendor\sparclex\nova-import-card\src\NovaImportCard.php

 */
public $width = '1/2';

public function __construct($resource)
{
    parent::__construct();
    $this->withMeta([
        'fields' => [
            new File('File'),
        ],
        'resourceLabel' => $resource::label(),// --- This line returned error

================================= laravelnovaimportcard laravelnovaimportcard

Sparclex commented 5 years ago

Hi @trueman52

If you replace new \Sparclex\NovaImportCard\NovaImportCard(App\Nova\User::class), with new \Sparclex\NovaImportCard\NovaImportCard(\App\Nova\User::class), you should be fine. You only forgot the backlash in front of the App\Nova\User::class and therefore php is looking for a class relatively to your current namespace which seems to be App\Providers

Please let me know if this fixes the issue.

Regards

Silvan

trueman52 commented 5 years ago

Thank you very much, Silvan!!!

Problem solved!

And big thanks for your time regarding this Nova package.

It can save a lot of time.