I want to used WhereIn method in Eloquent but it now work as below function
Messages: Call to undefined method Illuminate\Database\Query\JoinClause::whereIn()
Class Notificatin extends Model{
public function getNotification($user_id)
{
$this->_data = self::select('*')
->join('user_permission', function($join){
$join->on('n_user_id','=','user_id')->whereIn('permission_id',array(90,91,92,93));
})
->get();
if (count($this->_data)) {
return $this->_data;
} else {
return $this->_data;
}
}
}
You need to modify you join
query and put whereIn
clouse out side like:
$this->_data = self::select('*')
->join('user_permission', function($join){
$join->on('n_user_id','=','user_id');
})->whereIn('user_permission.permission_id',array(90,91,92,93))
->get();
Without using Joins :
whereIn / whereNotIn / orWhereIn / orWhereNotIn
The whereIn method verifies that a given column's value is contained within the given array:
$users = DB::table('users')
->whereIn('id', [1, 2, 3])
->get();
The whereNotIn method verifies that the given column's value is not contained in the given array:
$users = DB::table('users')
->whereNotIn('id', [1, 2, 3])
->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With