目前即時通訊使用Laravel-Excel文件(MaatWebsite),並要檢查Excel中的數據是否相同與數據庫 「傢俱」 表中的數據Laravel,檢查記錄是否存在並在表格中顯示它們的最佳/備選方法是什麼?
控制器
// assume $id is retrieve from parameter
$check_furnitures = Furniture::where('company_no', $id)->get();
$rows = Excel::load('storage\\app\\public\\upload\\furniture.xlsx', function($reader){$reader->noHeading();$reader->skipRows(1)})->get();
查看
<table>
<thead>
<tr>
<td>Chair Name></td>
<td>Desk Name></td>
<td>Carpet Name></td>
<td>Status</td>
</tr>
</thead>
<tbody>
<?php $arr = array(); ?>
@foreach($rows as $key => $value)
@foreach($check_furnitures as $fur)
@if(
$fur->chairs == $value[1] &&
$fur->desks == $value[2] &&
$fur->carpets == $pvalue[3]
)
<?php $temp_array[] = $value[0] ?>
@endif
@endforeach
@endforeach
<tr>
<td>{{$value[1]}}</td>
<td>{{$value[2]}}</td>
<td>{{$value[3]}}</td>
<td>
@foreach($arr as $test)
@if($test == $value[0])
DUPLICATED VALUE
@endif
@endforeach
</td>
<tr>
<table>
Excel文件
人?碰碰撞 – begineeeerrrr