Level 28
Well, first things first:
- Does the file app\Nova\Article.php exist?
- Is the class inside really called Article? (no typos)
- Is the namespace correct?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I created a 1 to n relationship between User and Article.
Model User:
public function articles()
{
return $this->hasMany(Article::class);
}
Model Article
public function articles()
{
return $this->hasMany(Article::class);
}
in Resource Nova I created Articles for Article, while the one for users is already defined:
Resource Articles:
public function fields(Request $request)
{
return [
ID::make(__('ID'), 'id')->sortable(),
Translatable::make([
Text::make('Title'),
Trix::make('Body'),
]),
DateTime::make('created_at'),
DateTime::make('updated_at'),
BelongsTo::make('User'),
Text::make('img'),
];
}
and here the relationship works.
while User side does not work:
Resource User:
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Gravatar::make()->maxWidth(50),
Text::make('Name')
->sortable()
->rules('required', 'max:255'),
Text::make('Email')
->sortable()
->rules('required', 'email', 'max:254')
->creationRules('unique:users,email')
->updateRules('unique:users,email,{{resourceId}}'),
Password::make('Password')
->onlyOnForms()
->creationRules('required', 'string', 'min:8')
->updateRules('nullable', 'string', 'min:8'),
HasMany::make('Article')
];
}
When I go to User I get the following error:
Class App\Nova\Article not found
Please or to participate in this conversation.