1
我開發一個應用程序與Laravel 5,我有2個表product
和Category
,該product
表中有一欄category_id
是指id
catgeory
表加入和where子句對孩子Laravel 5雄辯
我也有2種型號Category
和Product
問題: 我只需要一個簡單的功能添加到我的Category
模型,返回由產品加入了類別,其中product.sx_code = 0
與雄辯
如果什麼sx_code的值是一個變量? –
@JadJoubran然後你不能把它放在關係聲明中。你需要在查詢時應用它:'$ category-> specialProducts() - > where('sx_code',$ code) - > get()' – lukasgeiter
好吧,但在我的情況下,我需要指定列名稱.. ('table.sx_code',$ code) - > get();' –