我正在尝试访问在 url 中传递的变量以传递给新表单。我目前有一个客户端表,它与 Lifepolicy 表有 hasMany 关系。在为人寿政策构建创建表单时,我不断收到未定义的变量。(使用 Laravel 5.8)
这是我的代码:
class Lifepolicy extends Model
{
protected $guarded = [
'id'
];
public function client()
{
return $this->belongsTo(Client::class);
}
public function addLifepolicy($lifepolicy)
{
$this->lifepolicies()->create($lifepolicy);
}
}
class Client extends Model
{
protected $guarded = [
'id'
];
public function Lifepolicy()
{
return $this->hasMany(Lifepolicy::class);
}
}
public function create(Request $request, Client $client)
{
return view('lifepolicies.create', $client);
}
Route::resource('/client/{client}/lifepolicy', 'ClientLifepolicyController');
这是抛出错误的部分:
<form role="form" method="POST" action="/client/{{ $client->id }}/lifepolicy">
慕的地10843