ojessecruz
ojessecruz

Jessé Cruz

Verified

@ojessecruz

👨🏻‍💻 Software Engineer 🇧🇷🇺🇸 | Laravel Artisan | Always learning

71 Posts 2K Views

  • No matching results...
  • Searching...

/ 255

🔍 #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!

78

🚨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!

71

I had a few hours today to work on something I’ve been wanting to build. With a full-time job and kids, it’s tough to find time for personal projects, but I’m making small but steady progress every day.

Still need some work, but what u guys think?

ps.: first time showing to someone.

image

1

106

yes, it’s in Portuguese because I will launch in Brazil. But it will have multi language support

104