消息

Queue totalSize() and JobInterrupted Event in Laravel 13.31

发布
Queue totalSize() and JobInterrupted Event in Laravel 13.31 image

The Laravel team released v13.31.0 with a queue connection totalSize() method, a new JobInterrupted event, chaperone support for BelongsToMany pivot models, and more.

Queue Total Size

杰克·贝利斯 贡献了 totalSize() method, which answers the question "how many total jobs do I have on my queue connection right now?"

// 前
队列 :: totalPendingSize () + 队列 :: totalDelayedSize () + 队列 :: totalReservedSize ();
// 后
队列 :: totalSize ();

#61373 更多细节。

Job Interrupted Event

杰克·贝利斯 贡献了新的 JobInterrupted event that is fired when a job holding the Interruptible contract is interrupted by the worker. This allows you to listen for this event and perform any necessary cleanup or logging.

使用 Illuminate\Queue\Events\JobInterrupted ;
事件 :: JobInterrupted ::班级 , 功能 JobInterrupted $event) {
// Handle the job interruption
});

#61412 更多细节。

Chaperone Support for BelongsToMany Pivot Models

迦勒·怀特 contributed chaperone support for BelongsToMany pivot models. This allows you to use the chaperone() 方法 BelongsToMany relationship to retrieve the pivot model instance.

Many times when using custom pivot models, the BelongsTo relations can be defined on the model---however, trying to use them requires loading the models from the database even though both of the models are available during the BelongsToMany hydration.

...This PR adds chaperone support to the BelongsToMany relation, if a custom pivot model is not provided then calling ->chaperone() is a no-op.

班级 PostTagPivot 延伸
{
民众 功能 邮政 () : 属于
{
返回 $this -> 属于 邮政 ::班级 (英文):
}
民众 功能 标签 () : 属于
{
返回 $this -> 属于 标签 ::班级 (英文):
}
}
班级 标签 延伸 模型
{
民众 功能 帖子 () : 属于多个
{
返回 $this -> 属于多 邮政 ::班级
-> 使用 PostTagPivot ::班级
// automatically guesses relationship names
-> 伴侣 ();
// but can override if needed or non-standard
-> 伴侣 declaring : 'tag' , 有关的 : '邮政' (英文):
}
}
班级 邮政 延伸 模型
{
民众 功能 标签 () : 属于多个
{
返回 $this -> 属于多 标签 ::班级
-> 使用 PostTagPivot ::班级
-> 伴侣 declaring : '邮政' , 有关的 : 'tag' (英文):
}
}

#61152 更多细节。

Vite Dev Server URL

@ramonmalcolm10 贡献了一个 devServerUrl() method to the Vite class, which allows you to retrieve the URL of the Vite development server. This is useful for generating asset URLs in your application.

#61465 更多细节。

Once Assertions for Mail and Notification Fakes

@talaridisTh contributed new "once" assertions for the Mail and Notification fakes:

// 前
邮件 :: assertSentTimes 订单已发货 ::班级 , 1 (英文):
邮件 :: assertQueuedTimes 订单已发货 ::班级 , 1 (英文):
通知 :: assertSentToTimes ($user, InvoicePaid ::班级 , 1 (英文):
通知 :: assertSentOnDemandTimes InvoicePaid ::班级 , 1 (英文):
// 后
邮件 :: assertSentOnce 订单已发货 ::班级 (英文):
邮件 :: assertQueuedOnce 订单已发货 ::班级 (英文):
通知 :: assertSentToOnce ($user, InvoicePaid ::班级 (英文):
通知 :: assertSentOnDemandOnce InvoicePaid ::班级 (英文):

#61415 更多细节。

发行说明

您可以在下面查看新功能和更新的完整列表以及之间的差异 13.30.0 and 13.31.0 在 GitHub 上。以下发行说明直接来自 变更日志 :

v13.31.0

保罗·雷德蒙德照片

Laravel News 特约撰稿人。全栈 Web 开发人员兼作家。

赞助

laravelcloud logo
Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

访问 Laravel Cloud
PayZephyr: One Payment API for Stripe, Paystack, and PayPal image

PayZephyr: One Payment API for Stripe, Paystack, and PayPal

阅读文章
Bifrost Turns One With AI Builds and New Workflows image

Bifrost Turns One With AI Builds and New Workflows

阅读文章
Preview Blade Templates in macOS Finder with Quick Blade image

Preview Blade Templates in macOS Finder with Quick Blade

阅读文章
Artisan Debugging Commands in Laravel Telescope 5.24.0 image

Artisan Debugging Commands in Laravel Telescope 5.24.0

阅读文章
Find Unexpected Test Inputs with Fuzz for Pest image

Find Unexpected Test Inputs with Fuzz for Pest

阅读文章
Laravel Rulebook: Business Rules That Change by Date image

Laravel Rulebook: Business Rules That Change by Date

阅读文章