"Class 'App\Nova\Status' not found".
Sounds to me like you're missing an import somewhere, not actually a bug in the package. Can you post the full Resource file here?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
What to do in following case:
Select::make(__('Status'), 'status')->options(function () {
return [
'to_schedule' => '' . __('To Schedule') . '',
'quote_todo' => '' . __('Quote Todo') . '',
];
})
->rules('required'),
NovaBelongsToDepend::make(__('Responsible'), 'responsible_one', Employee::class)
->placeholder('Select')
->options(
\App\Models\Employee::all()
)->optionsResolve(function ($status) {
if ($status == 'quote_todo') {
//some code
}
})
->dependsOn('status'),
In above example I'm using this package. I have 1 normal select field and other model select field. My model data has to be filtered depending on status.
I'm getting internal error - "Class 'App\Nova\Status' not found".
You can also check issue created on GitHub.
Thank you for reading this post.
"Class 'App\Nova\Status' not found".
Sounds to me like you're missing an import somewhere, not actually a bug in the package. Can you post the full Resource file here?
@bobbybouwmann here is the resource file
<?php
namespace App\Nova;
use App\Nova\Filters\ProjectStatus;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Select;
use Orlyapps\NovaBelongsToDepend\NovaBelongsToDepend;
class Project extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = \App\Models\Project::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'title';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'id', 'title'
];
/**
* The pagination per-page options configured for this resource.
*
* @return array
*/
public static $perPageOptions = [10, 50, 100, 500];
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make(__('ID'), 'id')->sortable(),
Select::make(__('Status'), 'status')->options(function () {
return [
'to_schedule' => '' . __('To Schedule') . '',
'scheduled' => '' . __('Scheduled') . '',
'reschedule' => '' . __('Re-Schedule') . '',
'in_process' => '' . __('In Process') . '',
'finished' => '' . __('Finished') . '',
'quote_todo' => '' . __('Quote Todo') . '',
'quote_sent' => '' . __('Quote Sent') . '',
'quote_declined' => '' . __('Quote Declined') . ''
];
})
->displayUsingLabels()
->rules('required'),
NovaBelongsToDepend::make(__('Responsible') . ' 1', 'responsible_one', Employee::class)
->placeholder(__('Select') . ' ' . __('Responsible') . ' 1')
->options(
\App\Models\Employee::all()
),
NovaBelongsToDepend::make(__('Responsible') . ' 2', 'responsible_two', Employee::class)
->placeholder(__('Select') . ' ' . __('Responsible') . ' 2')
->options(
\App\Models\Employee::all()
)
->optionsResolve(function ($responsible_one) {
return \App\Models\Employee::leftJoin('role_permission', 'role_permission.role_id', '=', 'employees.role_id')
->where('role_permission.permission_slug', '=', config('nova-permissions.permissions.responsible_two.name'))
->where('id', '!=', $responsible_one->id)->get();
})
->dependsOn('responsible_one')
->nullable(),
];
}
/**
* Get the cards available for the request.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function cards(Request $request)
{
}
/**
* Get the filters available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function filters(Request $request)
{
return [
new ProjectStatus,
];
}
/**
* Get the lenses available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function lenses(Request $request)
{
return [];
}
/**
* Get the actions available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function actions(Request $request)
{
return [];
}
/**
* Get the displayable label of the resource.
*
* @return string
*/
public static function label()
{
return __('Projects');
}
/**
* Get the displayable singular label of the resource.
*
* @return string
*/
public static function singularLabel()
{
return __('Project');
}
}
You can see I have 1 normal select field with static data and 2 belongsTo fields. I want to filter data of belongsTo field depending on value selected in status select.
I don't see a reference to status anywhere in your code, only the field itself. I think you forgot to add the dependsOn('status') to the responsible_one field.
Also, this package (NovaBelongsToDepend) is only available for belongsTo relationships. Status doesn't have a relationship with Employee so you can't use that here as far as I understand from the package.
You can try this package instead: https://novapackages.com/packages/epartment/nova-dependency-container
@bobbybouwmann This NovaBelongsToDepend package is extending belongsTo field.
Below is the file
<?php
namespace Orlyapps\NovaBelongsToDepend;
use Illuminate\Support\Str;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\FormatsRelatableDisplayValues;
use Laravel\Nova\Fields\ResourceRelationshipGuesser;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Nova;
class NovaBelongsToDepend extends BelongsTo
{
use FormatsRelatableDisplayValues;
public $resourceParentClass;
public $modelClass;
public $modelPrimaryKey;
public $foreignKeyName;
public $valueKey;
public $titleKey;
public $dependKey;
public $dependsOn;
public $optionResolveCallback = null;
public $options = [];
public $fallback;
public $showLinkToResourceFromDetail = true;
public $showLinkToResourceFromIndex = true;
/**
* The field's component.
*
* @var string
*/
public $component = 'nova-belongsto-depend';
public function __construct($name, $attribute = null, $resource = null)
{
$resource = $resource ?? ResourceRelationshipGuesser::guessResource($name);
parent::__construct($name, $attribute, $resource);
$this->modelClass = get_class($resource::newModel());
$this->modelPrimaryKey = $resource::newModel()->getKeyName();
$this->titleKey = $resource::$title;
$this->optionResolveCallback = function () {
return [];
};
}
public function placeholder($placeholder)
{
$this->withMeta(['placeholder' => $placeholder]);
return $this;
}
public function openDirection(string $openDirection)
{
$this->withMeta(['openDirection' => $openDirection]);
return $this;
}
public function options($options)
{
$this->options = collect($options);
return $this;
}
public function optionsResolve($callback)
{
$this->optionResolveCallback = $callback;
return $this;
}
public function dependsOn($relationship)
{
$this->dependsOn = Str::lower($relationship);
return $this;
}
public function fallback($fallback)
{
$this->fallback = $fallback;
return $this;
}
/**
* @param $parentResourceClass
* @return self
*/
public function setResourceParentClass($parentResourceClass)
{
$this->resourceParentClass = $parentResourceClass;
return $this;
}
public function hideLinkToResourceFromDetail()
{
$this->showLinkToResourceFromDetail = false;
return $this;
}
public function hideLinkToResourceFromIndex()
{
$this->showLinkToResourceFromIndex = false;
return $this;
}
public function resolve($resource, $attribute = null)
{
$testInstance = new \ReflectionClass($resource);
if ($testInstance->isAnonymous()) {
return $this;
}
if ($resource instanceof Action) {
$this->resourceParentClass = get_class($resource);
return $this;
}
parent::resolve($resource, $attribute);
$this->resourceParentClass = get_class(Nova::newResourceFromModel($resource));
$foreign = $resource->{$this->attribute}();
$this->foreignKeyName = $foreign->getForeignKeyName();
if ($this->dependsOn) {
$this->dependKey = $resource->{$this->dependsOn}()->getForeignKeyName();
}
if ($resource->relationLoaded($this->attribute)) {
$value = $resource->getRelation($this->attribute);
}
if (empty($value)) {
$value = $resource->{$this->attribute}()->withoutGlobalScopes()->getResults();
}
if (!empty($value)) {
$this->valueKey = $value->getKey();
$this->value = $this->formatDisplayValue($value);
}
if ($this->fallback) {
$this->fallback->resolve($resource);
}
}
/**
* @param mixed $resource
* @param null $attribute
*/
public function resolveForDisplay($resource, $attribute = null)
{
parent::resolveForDisplay($resource, $attribute);
if ($resource->{$this->foreignKeyName} === null && $this->fallback) {
$this->value = $resource->{$this->fallback->attribute};
return;
}
$this->fallback = false;
}
/**
* Hydrate the given attribute on the model based on the incoming request.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @param object $model
* @return mixed
*/
public function fillForAction(NovaRequest $request, $model)
{
if (isset($request[$this->attribute])) {
$model->{$this->attribute} = $request[$this->attribute];
}
return $model->{$this->attribute};
}
/**
* Fills the attributes of the model within the container if the dependencies for the container are satisfied.
*
* @param NovaRequest $request
* @param string $requestAttribute
* @param object $model
* @param string $attribute
*/
protected function fillAttributeFromRequest(NovaRequest $request, $requestAttribute, $model, $attribute)
{
if ($request->exists($requestAttribute)) {
$model->{$attribute} = $request[$requestAttribute];
}
if ($this->fallback) {
$this->fallback->fill($request, $model);
}
}
/**
* Return the sortable uri key for the field.
*
* @return string
*/
public function sortableUriKey()
{
$request = app(NovaRequest::class);
return $this->getRelationForeignKeyName($request->newResource()->resource->{$this->attribute}());
}
public function meta()
{
$this->meta = parent::meta();
return array_merge([
'options' => $this->options,
'valueKey' => $this->valueKey,
'dependKey' => $this->dependKey,
'dependsOn' => $this->dependsOn,
'titleKey' => $this->titleKey,
'resourceParentClass' => $this->resourceParentClass,
'modelClass' => $this->modelClass,
'modelPrimaryKey' => $this->modelPrimaryKey,
'foreignKeyName' => $this->foreignKeyName,
'fallback' => $this->fallback,
'showLinkToResourceFromDetail' => $this->showLinkToResourceFromDetail,
'showLinkToResourceFromIndex' => $this->showLinkToResourceFromIndex
], $this->meta);
}
}
I was thinking of tweaking this package itself and pass data of normal select field and not just belongsTo field.
This package contains resolve function which checks for dependsOn as below
if ($this->dependsOn) {
$this->dependKey = $resource->{$this->dependsOn}()->getForeignKeyName();
}
Is there a way to tweak this class ?
@Ankit Zore Yeah, like I said. The package is only used for BelongsToMany relationships. You can't use it without a relationship. You either have to build something yourself or use a different pacakge.
I have managed to solve this issue by creating custom field which listen's to the event bus of dependent field. This code is inspired from NovaBelongsToDepend package with few modifications to listen to event bus. This new field is able to listen as well as emit data. Modifications as follows
public function listenTo($fieldAttribute)
{
return $this->withMeta(['listenTo' => $fieldAttribute . '-change']);
}
The change event is triggered by dependend field.
Please or to participate in this conversation.