在我的控制器中,我做了类似的事情:
<?php
class DashboardController extends Controller
{
public function index(){
$stock = DB::table('stock')
->join('quality', 'stock.qualityid', '=', 'quality.qualityid')
->select('stock.*', 'quality.name' )
->get();
$data['stock'] = $stock;
return view('dashboard', $data);
}
}
?>
and in my view (blade):
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HISFA -- Dashboard</title>
</head>
<body>
@foreach ($rawmaterial as $rawmaterials)
<p>Grondstof met naam {{ $rawmaterials->type }} heeft op dit moment een stock van {{ $rawmaterials->quantity }} octabins.</p>
@endforeach
</body>
</html>
在我的数据库中,我有一个表(库存包含字段:id,qualityid,height,quantity)和第二个表(Quality with fields:qualityid,type) 现在我想从每个不同类型的每个高度数量。
帮助将不胜感激!
答案 0 :(得分:0)
<?php
class DashboardController extends Controller
{
public function index(){
$stock = DB::table('stock')
->join('quality', 'stock.qualityid', '=', 'quality.qualityid')
->select('stock.*', 'quality.name' )
->get();
return view('dashboard', ['rawmaterials' => $stock]);
}
}
?>
and in my view (blade):
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HISFA -- Dashboard</title>
</head>
<body>
@foreach ($rawmaterials as $rawmaterial)
<p>Grondstof met naam {{ $rawmaterials->type }} heeft op dit moment een stock van {{ $rawmaterials->quantity }} octabins.</p>
@endforeach
</body>
</html>