samedi 31 août 2019

Call to undefined method Illuminate\Database\Query\Builder::unique()

I'm using database Query Builder in Laravel (5.5.46). In my database, one column has not unique values, so I want all the values from that column should be distinct or unique.

I used distinct() method but it discarded my repeated value. So I used unique() function. But I got this error.

$job_data = \DB::table('jobs')
                   ->orderBy('created_at', 'desc')
                   ->unique('job_id')->paginate(10);

In database {1,1,2,3,4,2}

I expect {1,2,3,4} but I got this error

BadMethodCallException

Call to undefined method Illuminate\Database\Query\Builder::unique()



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire