如何使用以下查询使用laravel eloquent执行where子句:
public class MyFragmentTest {
@Rule
public FragmentTestRule<MyFragment> mFragmentTestRule = new FragmentTestRule<>(MyFragment.class);
@Test
public void fragment_can_be_instantiated() {
// Launch the activity to make the fragment visible
mFragmentTestRule.launchActivity(null);
// Then use Espresso to test the Fragment
onView(withId(R.id.an_id_in_the_fragment)).check(matches(isDisplayed()));
}
}
我不知道如何为此修改此代码:
select * from stats where payed = 1 AND WHERE (user_id = 1 OR owner_id = 1)
答案 0 :(得分:3)
像这样改变
$payouts = Stat::where('payed', '1');
$payouts->where(function ($payouts) {
$payouts->where('owner_id', Auth::user()->id)
->orWhere('user_id', Auth::user()->id);
})->get();
答案 1 :(得分:0)
试试这个
$payouts = Stat::where('payed', '1')
->where(function ($query) {
$query->where('owner_id', Auth::user()->id)
->orwhere('user_id', Auth::user()->id);
})->get();
答案 2 :(得分:0)
你很接近,这应该可以解决问题:
$payouts = Stat::where('payed', '1')
->where(function ($query) {
$query->where('owner_id', Auth::user()->id)
->orWhere('user_id', Auth::user()->id);
})->get();
这是在寻找where payed = 1 AND (owner_id is the current user ID OR the user_id is the current user ID)