[英]Problems linking view and controller
This is the error I am getting on the sample view: 这是我在示例视图上遇到的错误:
Undefined variable: sampleRecord
This is the controller code: 这是控制器代码:
public function show($sample_id)
{
return View::make('samples.show')->with([
$this->sampleRepository->find($sample_id),
$this->sampleRecord->getSamplePartNumberRecord,
]);
}
This is the view code: 这是视图代码:
<p>{{ $sampleRecord }}</p>
@foreach($sampleRecord->SamplePartNumbers() as $samplePartNumberRecord)
<p>Sample Part Number: <br />{{ $samplePartNumberRecord }}</p>
@endforeach
your controller should be: 您的控制器应为:
public function show($sample_id)
{
return View::make('samples.show')->with([
"sampleRepository" => $this->sampleRepository->find($sample_id),
"sampleRecord" => $this->sampleRecord->getSamplePartNumberRecord,
]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.