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']);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire