I have two nova resources
Here is the the account address resource
class AccountAddress extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = \App\Models\AccountAddress::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'id';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'id',
];
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),
BelongsTo::make('Address Type', 'addressType', \App\Nova\AddressTypeMaster::class),
BelongsTo::make('Location', 'location', \App\Nova\LocationMaster::class),
BelongsTo::make('Street', 'street', \App\Nova\StreetMaster::class),
BelongsTo::make('City', 'city', \App\Nova\CityMaster::class),
BelongsTo::make('State', 'state', \App\Nova\StateMaster::class),
BelongsTo::make('Zip', 'zip', \App\Nova\ZipcodeMaster::class),
When I try to load this in the browser I'm getting this error
Undefined constant: "App\Nova\StateMaster"
Undefined constant: "App\Nova\LocationMaster"
Here is the State master Resource
class StateMaster extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = \App\Models\StateMaster::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'state_id';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'state_id',
];
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make('state_id')->sortable(),
Number::make('State id')
->rules('required', 'integer'),
Text::make('Country id')
->rules('required', 'string'),
Text::make('State code')
->rules('required', 'string'),
Text::make('State name')
->rules('required', 'string'),
Number::make('Status')
->rules('required', 'integer'),
];
}
Here is the relationship on the model
public function location(): BelongsTo
{
return $this->belongsTo(LocationMaster::class, 'location', 'location_id');
}
public function state(): BelongsTo
{
return $this->belongsTo(StateMaster::class, 'state', 'state_id');
}