mercredi 25 juillet 2018

Increment() and get() in one single query laravel

I have a table named advertisments which has views column. I want to fetch the data from advertisments table and increment each row's views in a single query is it possible ?.

The following code is what I wrote to achieve the desired result but the views aren't updating.

Advertisement::with('sponsor')
            ->whereDeleted(false)
            ->whereHeader(false)
            ->orderBy('views')
            ->raw("update views ".DB::raw('views + 1'))
            ->get();



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NJF7pZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire