ayushflitzip:
私は、複数の使用に複数でlaravelでwhere句の条件クエリに参加する方法を私に勧めてください。
私のテーブル名がある- :私は次のように使用を無効にテーブルから備えていcalllogユーザーの通話記録は、名前で存在し、別のテーブルここdisableappユーザーのステータスは1つのデータレコードが表示されたり、それが0の場合、データは私がこのJoinqueryを使用してください無効であるかのよう。
私のコードです。
$callrecordings = DB::table('callrecordings')
->join('users', 'users.id', '=', 'callrecordings.user_id')
->leftJoin('disableapp', 'callrecordings.user_id', '=', 'disableapp.user_id')
->select('callrecordings.*', 'users.expiry_date')
->where('callrecordings.user_id', '=', $user_id)
->where('disableapp.status', '=', 1)
->get();
if($callrecordings[0]->expiry_date <= Carbon::now()->toDateTimeString()){
return response()->json(['status'=>'Package Expired Sorry!', 'data'=>'']);
} else{
return $this->sendResponse($callrecordings->toArray(), 'Call Recordings retrieved successfully');
}
[![]ここに画像の説明を入力し、[1] [1] [![]ここに画像の説明を入力し、[2] [2]
レコードに示すdisableaapテーブルのブランクは、ユーザデータリストならば私は必要とそのステータスは、それが非表示になりますし、それが表示され、その後1ならば、0である場合。ユーザーはそれを行うために許可されますが、最初の時間は、それがレコードに表示されます。
私の使用したら
orwhere('disableapp.status', '=', Null)
それは秀私に解決策を提案してください私の問題を解決しませんでした
前もって感謝します
Malkhazi Dartsmelidze:
これは、問題を解決していますか?あなたはグループあなたのしたいときwhere
やorWheres
、パラメータとして使用する機能
$callrecordings = DB::table('callrecordings')
->join('users', 'users.id', '=', 'callrecordings.user_id')
->leftJoin('disableapp', 'callrecordings.user_id', '=', 'disableapp.user_id')
->select('callrecordings.*', 'users.expiry_date')
->where('callrecordings.user_id', '=', $user_id)
->where(function($q){
$q->where('disableapp.status', '=', 1)
->orWhereNull('disableapp.status');
})
->get();
if($callrecordings[0]->expiry_date <= Carbon::now()->toDateTimeString()){
return response()->json(['status'=>'Package Expired Sorry!', 'data'=>'']);
} else{
return $this->sendResponse($callrecordings->toArray(), 'Call Recordings retrieved successfully');
}