Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 莫弗托拉维尔新星酒店_Php_Laravel_Eloquent_Relationship - Fatal编程技术网

Php 莫弗托拉维尔新星酒店

Php 莫弗托拉维尔新星酒店,php,laravel,eloquent,relationship,Php,Laravel,Eloquent,Relationship,我有一个morpto-MorphMany关系,这样一个地址可以属于一个用户或一个组织。我一直在犯错误 调用未定义的方法App\HTTP\Resources\User::singularLabel() 我尝试使用静态方法,但似乎没有帮助。这些文件的代码如下所示 谢谢 Address.php模型 公共函数可寻址() { 返回$this->morphTo('addressable'); } 公共函数getHashidsConnection() { 返回“地址”; } User.php(模型) 公共职

我有一个morpto-MorphMany关系,这样一个地址可以属于一个用户或一个组织。我一直在犯错误

调用未定义的方法App\HTTP\Resources\User::singularLabel()

我尝试使用静态方法,但似乎没有帮助。这些文件的代码如下所示

谢谢

Address.php模型

公共函数可寻址()
{
返回$this->morphTo('addressable');
}
公共函数getHashidsConnection()
{
返回“地址”;
}
User.php(模型)

公共职能机构()
{
返回$this->belongsTo('App\organization');
}
公共活动地址()
{
返回$this->morphMany('App\Address','addressable');
}
Address.php(资源)

公共功能字段(请求$Request)
{
返回[
ID::make()->sortable(),
Text::make('line_1'),
Text::make('line_2'),
Text::make('line_3'),
Text::make('post_code'),
布尔::make('is_primary'),
MorphTo::make('Addressable')->类型([
用户::类,
组织:班级,
])
];
}
公共静态函数标签()
{
返回地址::类;
}
User.php(资源)

公共功能字段(请求$Request)
{
返回[
ID::make()->sortable(),
Gravatar::make(),
Text::make('Name')
->可排序的()
->规则('required','max:255'),
Text::make('Email')
->可排序的()
->规则('必需','电子邮件','最大值:254')
->creationRules('唯一:用户,电子邮件')
->updateRules('unique:users,email,{{resourceId}}'),
密码::make('Password')
->onlyOnForms()
->creationRules('必需'、'字符串'、'最小值:8')
->updateRules('nullable','string','min:8'),
MorphMany::make('地址')
];
}

您确定在下面的代码中Address.php(资源)中使用nova ressource而不是用户和组织的模型吗

MorphTo::make('Addressable')->types([ 
  User::class,
  Organisation::class,
])