Exception Creating New Resource in Laravel Nova - Class 'AppPost' not found












1














I have a brand new installation of Laravel Nova. The dashboard comes up fine. But when I add a new resource using php artisan nova:resource Post and reload the dashboard, it's throwing an error. When I remove the offending model from Nova folder, dashboard works again. I'm following the step by step instructions from the Nova docs exactly. I can't figure it out.



Screenshot
Screenshot



navigation.blade.php



@if (count(Nova::availableResources(request())))
<h3 class="flex items-center font-normal text-white mb-6 text-base no-underline">
<svg class="sidebar-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path fill="var(--sidebar-icon)" d="M3 1h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3h-4zM3 11h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4h-4z"
/>
</svg>
<span class="sidebar-label">{{ __('Resources') }}</span>
</h3>

@foreach(Nova::groupedResources(request()) as $group => $resources)
@if (count($resources) > 0)
@if (count(Nova::groups(request())) > 1)
<h4 class="ml-8 mb-4 text-xs text-white-50% uppercase tracking-wide">{{ $group }}</h4>
@endif

<ul class="list-reset mb-8">
@foreach($resources as $resource)
@if (! $resource::$displayInNavigation)
@continue
@endif

<li class="leading-tight mb-4 ml-8 text-sm">
<router-link :to="{
name: 'index',
params: {
resourceName: '{{ $resource::uriKey() }}'
}
}" class="text-white text-justify no-underline dim">
{{ $resource::label() }}
</router-link>
</li>
@endforeach
</ul>
@endif
@endforeach
@endif


I see that the Blade is calling @foreach($resources as $resource), which is where I assume the code is failing. The docs say:



"Automatic Registration -- By default, all resources within the app/Nova directory will automatically be registered with Nova. You are not required to manually register them. Before resources are available within your Nova dashboard, you must register them with Nova. Resources get registered in your app/Providers/NovaServiceProvider.php file. This file contains various configuration and bootstrapping code related to your Nova installation."



But when I look at app/Providers/NovaServiceProvider.php there are no resources listed:



<?php
namespace AppProviders;

use LaravelNovaNova;
use LaravelNovaCardsHelp;
use IlluminateSupportFacadesGate;
use LaravelNovaNovaApplicationServiceProvider;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
public function boot()
{
parent::boot();
}

protected function gate()
{
Gate::define('viewNova', function ($user) {
return in_array($user->email, [
//
]);
});
}

protected function cards()
{
return [
new Help,
];
}

public function tools()
{
return ;
}
}


Unfortunately, when I paste in the suggested code for manually registering the resources, it still doesn't work.



<?php

use AppNovaUser;
use AppNovaPost;

protected function resources()
{
Nova::resourcesIn(app_path('Nova'));

Nova::resources([
User::class,
Post::class,
]);
}









share|improve this question
























  • can you post you navigation.blade.php?
    – Dearwolves
    Nov 21 at 4:02










  • I just found you a possible fix . Take a look here github.com/laravel/nova-issues/issues/55
    – Dearwolves
    Nov 21 at 4:06










  • Thanks Dearwolves. I saw that post. Didn't help, unfortunately.
    – Rick Leckrone
    Nov 21 at 18:18










  • navigation.blade.php posted above
    – Rick Leckrone
    Nov 21 at 18:18










  • Here's the deal. There is a file called User.php in the App directory - NOT THE ONE IN THE App/Nova directory where the resource is created. But actually in the App directory. When you create a new resource, you have to create a duplicate of this file with the name of your resource. So in my case, copy the file and create Images.php in the App directory. This fixes the issue. Artisan does NOT create this file automatically.
    – Rick Leckrone
    Nov 21 at 21:37
















1














I have a brand new installation of Laravel Nova. The dashboard comes up fine. But when I add a new resource using php artisan nova:resource Post and reload the dashboard, it's throwing an error. When I remove the offending model from Nova folder, dashboard works again. I'm following the step by step instructions from the Nova docs exactly. I can't figure it out.



Screenshot
Screenshot



navigation.blade.php



@if (count(Nova::availableResources(request())))
<h3 class="flex items-center font-normal text-white mb-6 text-base no-underline">
<svg class="sidebar-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path fill="var(--sidebar-icon)" d="M3 1h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3h-4zM3 11h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4h-4z"
/>
</svg>
<span class="sidebar-label">{{ __('Resources') }}</span>
</h3>

@foreach(Nova::groupedResources(request()) as $group => $resources)
@if (count($resources) > 0)
@if (count(Nova::groups(request())) > 1)
<h4 class="ml-8 mb-4 text-xs text-white-50% uppercase tracking-wide">{{ $group }}</h4>
@endif

<ul class="list-reset mb-8">
@foreach($resources as $resource)
@if (! $resource::$displayInNavigation)
@continue
@endif

<li class="leading-tight mb-4 ml-8 text-sm">
<router-link :to="{
name: 'index',
params: {
resourceName: '{{ $resource::uriKey() }}'
}
}" class="text-white text-justify no-underline dim">
{{ $resource::label() }}
</router-link>
</li>
@endforeach
</ul>
@endif
@endforeach
@endif


I see that the Blade is calling @foreach($resources as $resource), which is where I assume the code is failing. The docs say:



"Automatic Registration -- By default, all resources within the app/Nova directory will automatically be registered with Nova. You are not required to manually register them. Before resources are available within your Nova dashboard, you must register them with Nova. Resources get registered in your app/Providers/NovaServiceProvider.php file. This file contains various configuration and bootstrapping code related to your Nova installation."



But when I look at app/Providers/NovaServiceProvider.php there are no resources listed:



<?php
namespace AppProviders;

use LaravelNovaNova;
use LaravelNovaCardsHelp;
use IlluminateSupportFacadesGate;
use LaravelNovaNovaApplicationServiceProvider;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
public function boot()
{
parent::boot();
}

protected function gate()
{
Gate::define('viewNova', function ($user) {
return in_array($user->email, [
//
]);
});
}

protected function cards()
{
return [
new Help,
];
}

public function tools()
{
return ;
}
}


Unfortunately, when I paste in the suggested code for manually registering the resources, it still doesn't work.



<?php

use AppNovaUser;
use AppNovaPost;

protected function resources()
{
Nova::resourcesIn(app_path('Nova'));

Nova::resources([
User::class,
Post::class,
]);
}









share|improve this question
























  • can you post you navigation.blade.php?
    – Dearwolves
    Nov 21 at 4:02










  • I just found you a possible fix . Take a look here github.com/laravel/nova-issues/issues/55
    – Dearwolves
    Nov 21 at 4:06










  • Thanks Dearwolves. I saw that post. Didn't help, unfortunately.
    – Rick Leckrone
    Nov 21 at 18:18










  • navigation.blade.php posted above
    – Rick Leckrone
    Nov 21 at 18:18










  • Here's the deal. There is a file called User.php in the App directory - NOT THE ONE IN THE App/Nova directory where the resource is created. But actually in the App directory. When you create a new resource, you have to create a duplicate of this file with the name of your resource. So in my case, copy the file and create Images.php in the App directory. This fixes the issue. Artisan does NOT create this file automatically.
    – Rick Leckrone
    Nov 21 at 21:37














1












1








1







I have a brand new installation of Laravel Nova. The dashboard comes up fine. But when I add a new resource using php artisan nova:resource Post and reload the dashboard, it's throwing an error. When I remove the offending model from Nova folder, dashboard works again. I'm following the step by step instructions from the Nova docs exactly. I can't figure it out.



Screenshot
Screenshot



navigation.blade.php



@if (count(Nova::availableResources(request())))
<h3 class="flex items-center font-normal text-white mb-6 text-base no-underline">
<svg class="sidebar-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path fill="var(--sidebar-icon)" d="M3 1h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3h-4zM3 11h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4h-4z"
/>
</svg>
<span class="sidebar-label">{{ __('Resources') }}</span>
</h3>

@foreach(Nova::groupedResources(request()) as $group => $resources)
@if (count($resources) > 0)
@if (count(Nova::groups(request())) > 1)
<h4 class="ml-8 mb-4 text-xs text-white-50% uppercase tracking-wide">{{ $group }}</h4>
@endif

<ul class="list-reset mb-8">
@foreach($resources as $resource)
@if (! $resource::$displayInNavigation)
@continue
@endif

<li class="leading-tight mb-4 ml-8 text-sm">
<router-link :to="{
name: 'index',
params: {
resourceName: '{{ $resource::uriKey() }}'
}
}" class="text-white text-justify no-underline dim">
{{ $resource::label() }}
</router-link>
</li>
@endforeach
</ul>
@endif
@endforeach
@endif


I see that the Blade is calling @foreach($resources as $resource), which is where I assume the code is failing. The docs say:



"Automatic Registration -- By default, all resources within the app/Nova directory will automatically be registered with Nova. You are not required to manually register them. Before resources are available within your Nova dashboard, you must register them with Nova. Resources get registered in your app/Providers/NovaServiceProvider.php file. This file contains various configuration and bootstrapping code related to your Nova installation."



But when I look at app/Providers/NovaServiceProvider.php there are no resources listed:



<?php
namespace AppProviders;

use LaravelNovaNova;
use LaravelNovaCardsHelp;
use IlluminateSupportFacadesGate;
use LaravelNovaNovaApplicationServiceProvider;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
public function boot()
{
parent::boot();
}

protected function gate()
{
Gate::define('viewNova', function ($user) {
return in_array($user->email, [
//
]);
});
}

protected function cards()
{
return [
new Help,
];
}

public function tools()
{
return ;
}
}


Unfortunately, when I paste in the suggested code for manually registering the resources, it still doesn't work.



<?php

use AppNovaUser;
use AppNovaPost;

protected function resources()
{
Nova::resourcesIn(app_path('Nova'));

Nova::resources([
User::class,
Post::class,
]);
}









share|improve this question















I have a brand new installation of Laravel Nova. The dashboard comes up fine. But when I add a new resource using php artisan nova:resource Post and reload the dashboard, it's throwing an error. When I remove the offending model from Nova folder, dashboard works again. I'm following the step by step instructions from the Nova docs exactly. I can't figure it out.



Screenshot
Screenshot



navigation.blade.php



@if (count(Nova::availableResources(request())))
<h3 class="flex items-center font-normal text-white mb-6 text-base no-underline">
<svg class="sidebar-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path fill="var(--sidebar-icon)" d="M3 1h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3h-4zM3 11h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4h-4z"
/>
</svg>
<span class="sidebar-label">{{ __('Resources') }}</span>
</h3>

@foreach(Nova::groupedResources(request()) as $group => $resources)
@if (count($resources) > 0)
@if (count(Nova::groups(request())) > 1)
<h4 class="ml-8 mb-4 text-xs text-white-50% uppercase tracking-wide">{{ $group }}</h4>
@endif

<ul class="list-reset mb-8">
@foreach($resources as $resource)
@if (! $resource::$displayInNavigation)
@continue
@endif

<li class="leading-tight mb-4 ml-8 text-sm">
<router-link :to="{
name: 'index',
params: {
resourceName: '{{ $resource::uriKey() }}'
}
}" class="text-white text-justify no-underline dim">
{{ $resource::label() }}
</router-link>
</li>
@endforeach
</ul>
@endif
@endforeach
@endif


I see that the Blade is calling @foreach($resources as $resource), which is where I assume the code is failing. The docs say:



"Automatic Registration -- By default, all resources within the app/Nova directory will automatically be registered with Nova. You are not required to manually register them. Before resources are available within your Nova dashboard, you must register them with Nova. Resources get registered in your app/Providers/NovaServiceProvider.php file. This file contains various configuration and bootstrapping code related to your Nova installation."



But when I look at app/Providers/NovaServiceProvider.php there are no resources listed:



<?php
namespace AppProviders;

use LaravelNovaNova;
use LaravelNovaCardsHelp;
use IlluminateSupportFacadesGate;
use LaravelNovaNovaApplicationServiceProvider;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
public function boot()
{
parent::boot();
}

protected function gate()
{
Gate::define('viewNova', function ($user) {
return in_array($user->email, [
//
]);
});
}

protected function cards()
{
return [
new Help,
];
}

public function tools()
{
return ;
}
}


Unfortunately, when I paste in the suggested code for manually registering the resources, it still doesn't work.



<?php

use AppNovaUser;
use AppNovaPost;

protected function resources()
{
Nova::resourcesIn(app_path('Nova'));

Nova::resources([
User::class,
Post::class,
]);
}






php laravel laravel-routing laravel-nova laravel-resource






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 2 at 3:54









Karl Hill

2,19311740




2,19311740










asked Nov 21 at 3:11









Rick Leckrone

105




105












  • can you post you navigation.blade.php?
    – Dearwolves
    Nov 21 at 4:02










  • I just found you a possible fix . Take a look here github.com/laravel/nova-issues/issues/55
    – Dearwolves
    Nov 21 at 4:06










  • Thanks Dearwolves. I saw that post. Didn't help, unfortunately.
    – Rick Leckrone
    Nov 21 at 18:18










  • navigation.blade.php posted above
    – Rick Leckrone
    Nov 21 at 18:18










  • Here's the deal. There is a file called User.php in the App directory - NOT THE ONE IN THE App/Nova directory where the resource is created. But actually in the App directory. When you create a new resource, you have to create a duplicate of this file with the name of your resource. So in my case, copy the file and create Images.php in the App directory. This fixes the issue. Artisan does NOT create this file automatically.
    – Rick Leckrone
    Nov 21 at 21:37


















  • can you post you navigation.blade.php?
    – Dearwolves
    Nov 21 at 4:02










  • I just found you a possible fix . Take a look here github.com/laravel/nova-issues/issues/55
    – Dearwolves
    Nov 21 at 4:06










  • Thanks Dearwolves. I saw that post. Didn't help, unfortunately.
    – Rick Leckrone
    Nov 21 at 18:18










  • navigation.blade.php posted above
    – Rick Leckrone
    Nov 21 at 18:18










  • Here's the deal. There is a file called User.php in the App directory - NOT THE ONE IN THE App/Nova directory where the resource is created. But actually in the App directory. When you create a new resource, you have to create a duplicate of this file with the name of your resource. So in my case, copy the file and create Images.php in the App directory. This fixes the issue. Artisan does NOT create this file automatically.
    – Rick Leckrone
    Nov 21 at 21:37
















can you post you navigation.blade.php?
– Dearwolves
Nov 21 at 4:02




can you post you navigation.blade.php?
– Dearwolves
Nov 21 at 4:02












I just found you a possible fix . Take a look here github.com/laravel/nova-issues/issues/55
– Dearwolves
Nov 21 at 4:06




I just found you a possible fix . Take a look here github.com/laravel/nova-issues/issues/55
– Dearwolves
Nov 21 at 4:06












Thanks Dearwolves. I saw that post. Didn't help, unfortunately.
– Rick Leckrone
Nov 21 at 18:18




Thanks Dearwolves. I saw that post. Didn't help, unfortunately.
– Rick Leckrone
Nov 21 at 18:18












navigation.blade.php posted above
– Rick Leckrone
Nov 21 at 18:18




navigation.blade.php posted above
– Rick Leckrone
Nov 21 at 18:18












Here's the deal. There is a file called User.php in the App directory - NOT THE ONE IN THE App/Nova directory where the resource is created. But actually in the App directory. When you create a new resource, you have to create a duplicate of this file with the name of your resource. So in my case, copy the file and create Images.php in the App directory. This fixes the issue. Artisan does NOT create this file automatically.
– Rick Leckrone
Nov 21 at 21:37




Here's the deal. There is a file called User.php in the App directory - NOT THE ONE IN THE App/Nova directory where the resource is created. But actually in the App directory. When you create a new resource, you have to create a duplicate of this file with the name of your resource. So in my case, copy the file and create Images.php in the App directory. This fixes the issue. Artisan does NOT create this file automatically.
– Rick Leckrone
Nov 21 at 21:37

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404755%2fexception-creating-new-resource-in-laravel-nova-class-app-post-not-found%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404755%2fexception-creating-new-resource-in-laravel-nova-class-app-post-not-found%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'