Android Engineering

Android engineering is a field of software development that focuses on creating applications for the Android operating system, which is used by millions of people worldwide. With the increasing…


独家优惠奖金 100% 高达 1 BTC + 180 免费旋转

Running Laravel jobs with deleted models

If you try to dispatch a job with a model just after it was deleted, you will encounter a small problem:

Fortunately, there’s a quick fix for that — just remove SerializesModels trait from the job class. The trait causes the job to retrieve the model instance from database when it is being processed in the queue. This is a prefered behaviour in many cases, but not this one.

Without this trait the whole instance is serialized when dispatching and restored without database involvement when processing in the queue, which is exactly what we want.

This might also serve as optimization technique, saving you some database queries.

P.S. There’s no such problem when processing soft-deleted items, as models are still in the database when processing the queue.

Add a comment

Related posts:

The Future of Design Education Pt. 313

As the skill sets across a design team grow in breadth and depth, it is integral that the team shares valuable knowledge across the team. This begins with the understanding that the domain expertise…

The Best Oscar acceptance speech ever

You know just in a case I had to thank someone, and I don’t wanna forget nobody, so Let’s do this fast, first off all the foreign associated press thanks for having me here,I don’t know who or what…

Buy Negative Google Reviews

Search engine optimization (SEO) is an important part of online marketing. It helps businesses increase their visibility on search engines, such as Google. But, what if you want to gain visibility…