Laravel Idea for PhpStorm - Full-featured IDE for productive artisans!

Cancel Pending Notifications Immediately in Laravel 8.50

Published on by

Cancel Pending Notifications Immediately in Laravel 8.50 image

The Laravel team released v8.50.0 this week with the ability to cancel pending notifications, "pruneable" models, commonmark v2 support, and the latest changes in the 8.x branch:

Cancel Notifications

Graham Bradley contributed the ability to cancel notifications immediately before sending. To determine if a notification should be sent, you can now conveniently add custom logic around your notification class using the shouldSend method:

public function shouldSend($notifiable, $channel)
{
// custom logic
return true;
}

I'd encourage you to check out the pull request description for further details on what this accomplishes.

Prunable Models

Nuno Maduro contributed a way to remove obsolete records by making Laravel models "prunable":

When making models prunable, Laravel will automatically remove obsolete model records from the database via a scheduled command.

Here's an example of a prunable model from the pull request's description:

namespace App\Models;
 
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable; // or MassPrunable
 
class Post extends Model
{
use Prunable; // or MassPrunable
 
/**
* Determines the prunable query.
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function prunable()
{
return $this->where('created_at', '<=', now()->subMonth());
}
}

Coupled with a scheduled task of running artisan model:prune, Laravel will automatically detect prunable support and keep database records tidy. Pull Request #37889 has excellent details on how model pruning works.

Commonmark V2 Support

Colin O'Dell contributed support for both Commonmark v1 and v2. With the upcoming commonmark release, users of Laravel 8.x can install either major version of the CommonMark library.

Exclude Array Keys Not Included In Validation Rules

Mohamed Said contributed an opt-in method you can add to a service provider that will exclude array keys not included in validation rules:

// In a service provider
Validator::excludeUnvalidatedArrayKeys();
 
// Will not return keys without validation rules
// For example, users.*.email would not be returned (if "email" were a key)
request()->validate([
'users' => 'required|array',
'users.*.name' => 'required',
]);

Since this is potentially a breaking change, this feature is opt-in in Laravel 8.

Release Notes

You can see the full list of new features and updates below and the diff between 8.49.0 and 8.50.0 on GitHub. The following release notes are directly from the changelog

v8.50.0

Added

  • Added ability to cancel notifications immediately prior to sending (#37930)
  • Added the possibility of having "Prunable" models (#37889)
  • Added support for both CommonMark 1.x and 2.x (#37954)
  • Added Illuminate/Validation/Factory::excludeUnvalidatedArrayKeys() (#37943)

Fixed

  • Fixed Illuminate/Bus/PendingBatch::add() (108385b)
  • Cursor pagination fixes (#37915)

Changed

  • Mixed orders in cursor paginate (#37762)
  • Clear config after dumping auto-loaded files (#37985)
Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate logo

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate

Build your SaaS application in hours. Out-of-the-box multi-tenancy and seamless Stripe integration. Supports subscriptions and one-time purchases, allowing you to focus on building and creating without repetitive setup tasks.

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector
MongoDB logo

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB

The latest

View all →
Asymmetric Property Visibility in PHP 8.4 image

Asymmetric Property Visibility in PHP 8.4

Read article
Access Laravel Pulse Data as a JSON API image

Access Laravel Pulse Data as a JSON API

Read article
Laravel Forge adds Statamic Integration image

Laravel Forge adds Statamic Integration

Read article
Transform Data into Type-safe DTOs with this PHP Package image

Transform Data into Type-safe DTOs with this PHP Package

Read article
PHPxWorld - The resurgence of PHP meet-ups with Chris Morrell image

PHPxWorld - The resurgence of PHP meet-ups with Chris Morrell

Read article
Herd Executable Support and Pest 3 Mutation Testing in PhpStorm 2024.3 image

Herd Executable Support and Pest 3 Mutation Testing in PhpStorm 2024.3

Read article