How to pass a collection created without a model to a view file?
$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'));
view file(ckv.blade.php)
<table class="table table-striped">
@foreach($mpc as $post)
<tr>
<td></td>
<td></td>
<td></td>
</tr>
@endforeach
</table>
web.php
Route::get('/mischkp', 'CRUDController@mischkp');
The program checks for changed values of products over a day. The program is working but the view file is not accepting mpc.
from Laravel Questions and Answers https://laravelquestions.com/laravel/how-to-pass-a-collection-created-without-a-model-to-a-view-file/
via Lzo Media
No comments:
Post a Comment