jeudi 26 novembre 2015

Unable to select all records from one table that do not exist in another table Laravel 5.1?

i want to get all the records from a table which do not exist in other table in LARAVEL 5.1.

I know how to do this in core php, and it works fine with the following code

SELECT t1.name
FROM table1 t1
LEFT JOIN table2 t2 ON t2.name = t1.name
WHERE t2.name IS NULL

but when i try to do the same in Laravel by using the following code,

$all_bridal_requests_check = \DB::table('bridal_requests')
                    ->where(function($query)
                    {
                        $query->where('publisher', '=', 'bq-quotes.sb.com')
                              ->orWhere('publisher', '=', 'bq-wd.com-bsf');
                    })
                    ->whereNotIn('id', function($query) { $query->table('audiences')->select('request_id'); })
                    ->orderBy('created_on', 'desc')
                    ->get();

then it gives me this error
Call to undefined method Illuminate\Database\Query\Builder::table()

Please help me to sort out this problem.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire