
Jessé Cruz
@ojessecruz
👨🏻💻 Software Engineer 🇧🇷🇺🇸 | Laravel Artisan | Always learning
• • 72 Posts • 3K Views
🔍 #LaravelTip: Need a job to execute immediately within another job?
❌ Job::dispatch()->onConnection('sync')
✅ Job::dispatchSync()
The first one just sets queue connection, while dispatchSync() guarantees immediate execution before next line.
Key for data consistency!
🚨Laravel Tip: Avoid Race Conditions in Jobs
❌Bad:
$model->items()->create([...]);
$item = $model->items()->first();
✅Good:
$item = $model->items()->create([...]);
Why? Even in isolated jobs, first() can return null because:
- New DB query
- Cache inconsistency
- Commit delays
Always store the create() result directly!
Hey Laravel developers, looking to make your app multilingual? Fear not! This Filament plugin is here to save the day.
t.co/LaZOwOoN7g