lundi 29 octobre 2018

Duplicate Queries in Laravel- Debugger

I am trying to update the columns of the records based on the other column records but it results in the duplicate queries since its being executed for each record in the table.I s there a way to avoid it and improve this code.

 public function updateReviewColumn(){
        $reviewData = $this->pluck('indicator')->toArray();
        foreach ($reviewData as $datum) {
            if ($datum == 'Y')
                $this->where('indicator', $datum)
                    ->update(['reviewindicator' => 'Yes']);
            else
                $this->where('indicator', $datum)
                    ->update(['reviewindicator' => 'No']);
        }
    }



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

Aucun commentaire:

Enregistrer un commentaire