В моем проекте Laravel Nova у меня есть страница и PageTranslation (модель и ресурс).При добавлении hasMany к моим полям ресурса, после посещения детали страницы, я получаю ошибку 404.Это мой код
Это мой ресурс страницы
<?php
namespace App\Pages\Resources;
use Illuminate\Http\Request;
use Laravel\Nova\Resource;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\HasMany;
class Page extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = 'App\Pages\Models\Page';
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'working_title';
/**
* @var string
*/
public static $group = 'Pages';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'id', 'working_title'
];
/**
* Eager load translations
*/
public static $with = ['translations'];
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Text::make('Title', 'working_title')
->sortable()
->rules('required', 'max:256'),
HasMany::make('Translations', 'translations', \App\Pages\Resources\PageTranslation::class)
];
}
}
Это мой ресурс перевода страниц
<?php
namespace Codedor\Pages\Resources;
use Illuminate\Http\Request;
use Laravel\Nova\Resource;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
class PageTranslation extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = 'Codedor\Pages\Models\PageTranslation';
/**
* Hide resource from Nova's standard menu.
* @var bool
*/
public static $displayInNavigation = false;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Text::make('Locale')
->sortable()
->rules('required', 'max:256')
];
}
}