$mp=DB::table('miip')->get();
$mc=DB::table('mii')->get();
$mpc=collect([]);
foreach($mp as $post1)
{ foreach($mc as $post2)
{
if($post1->mipname==$post2->miname)
{
if($post1->mipvalue!=$post2->mivalue)
{
$mpc->name=$post1->mipname;
$mpc->pvalue=$post1->mipvalue;
$mpc->cvalue=$post2->mivalue;
}
}
}
}
return view('crud/ckv', compact('mpc'));
查看文件(ckv.blade.php)
<table class="table table-striped">
@foreach($mpc as $post)
<tr>
<td>{{$post->name}}</td>
<td>{{$post->pvalue}}</td>
<td>{{$post->cvalue}}</td>
</tr>
@endforeach
</table>
web.php
Route::get('/mischkp', 'CRUDController@mischkp');
该程序检查一天内产品的更改值。该程序正在运行,但视图文件不接受mpc。
答案 0 :(得分:1)
如果需要,您可以将所有三个项目传回刀片:
http://127.0.0.1:5500/api.openweathermap.org/data/2.5/weather?lat=30.18&lon=30.87&appid=57d9478b#####################3b79272 404 (Not Found)
您可以在使用 $data = [
'mp' => $mp,
'mc' => $mc,
'mpc' => $mpc,
];
return view('crud/ckv', $data);
dd()
为了比较数据是否传递给视图,您可以将每个对象转储到刀片中以查看其中的内容:
dd($data);
答案 1 :(得分:0)
像往常一样传递变量:
return view('your.view', ['mpc' => $mpc]);
或者:
return view('your.view', (compact('mpc'));
或者:
return view('your.view')->with('mpc', $mpc);
答案 2 :(得分:0)
代码中的一个小变化 -
$mp=DB::table('miip')->get();
$mc=DB::table('mii')->get();
$mpc=collect([]);
foreach($mp as $post1)
{
$temp = new \stdClass();
foreach($mc as $post2)
{
if($post1->mipname==$post2->miname)
{
if($post1->mipvalue!=$post2->mivalue)
{
$temp->name=$post1->mipname;
$temp->pvalue=$post1->mipvalue;
$temp->cvalue=$post2->mivalue;
}
}
}
$mpc->push($temp);
}