【发布时间】:2021-08-30 04:05:53
【问题描述】:
请帮助我。我有这 3 个表,我在如何根据 restaurant id 从 Controller 到 view 调用 category name 时遇到问题。提前谢谢你。
表items
表categories
表restorant
这是我的Controller
public function index()
{
if (auth()->user()->hasRole('owner')) {
$items = Items::with('category')->get();
$restorant_id = auth()->user()->restorant->id;
$category = Categories::where(['restorant_id' => $restorant_id]);
}
return view('point-of-sale::index', [
'category' => $category,
'items' => $items,
]);
}
【问题讨论】:
标签: laravel view controller laravel-8