Laravel 4 - How to use where conditions for relation's column

后端 未结 2 1704
[愿得一人]
[愿得一人] 2021-02-09 14:31

This is what I want, I have two tables. one is \'Restaurants\' and other is \'Facilities\'.

The tables are simple.. and One-To-One relations. like there is a restaurant

2条回答
  •  臣服心动
    2021-02-09 15:10

    There are some ways to filter both, this is using QueryBuilder:

    Restaurant::join('facilities','facilities.restaurant_id','=','restaurants.id')
                    ->where('name','bbq')
                    ->where('facilities.wifi','!=', 1)
                    ->get();
    

提交回复
热议问题