Duplicate constraint error when using laravelsyncWithPivotValue method
P粉884667022
P粉884667022 2023-09-14 10:25:33
0
1
545

I have the following table (MySQL):

This line of code in my asset model (mainly called by asynchronous jobs):

$this->sites()->syncWithPivotValues($sites, ['is_current_site' => true]);

My problem is that when I do this line I keep getting duplicate constraint errors and I don't understand why. Any ideas?

P粉884667022
P粉884667022

reply all(1)
P粉068486220

The problem I am facing is the concurrency issue between jobs.

I used the WithoutOverlapping middleware (https://laravel.com /docs/9.x/queues#preventing-job-overlaps) to prevent concurrency problems on my jobs, and the effect is very good .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template