Any idea what's causing it?
This is my observer
public function updated(StartRonde $startRonde): void
{
// Check if scans are not empty
if (!empty($startRonde->scans)) {
// Count the number of references in scans
$scanCount = count($startRonde->scans);
// Fetch the associated ronde and its pointeaux
$ronde = $startRonde->ronde; // Assuming you have a relationship defined
$pointeauCount = $ronde->pointeaux()->count(); // Count the pointeaux
// Check if the counts are equal
if ($scanCount === $pointeauCount) {
// Add your logic here, for example, log a message or update a field
$startRonde->status = 'finished';
$startRonde->save(); // Save the changes to the database
} else {
// Logic for when counts do not match (optional)
Log::warning('Reference count does not match the number of Pointeaux for StartRonde ID: ' . $startRonde->id);
}
}
}