Laravel 7.19 Released

Published on by

Laravel 7.19 Released image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

The Laravel team released v7.19.0 with new scheduler frequency shortcuts, conditionally appending attributes to API resources and a new Stringable when() method:

Scheduler Frequency Shortcuts

Sjors Ottjes contributed more useful scheduler frequency shortcuts:

  • everyTwoHours()
  • everyThreeHours()
  • everyFourHours()
  • everySixHours()

They provide readable shortcuts instead of using cron:

// Using cron
$schedule->job(SyncSomething::class)->cron('0 */2 * * *');
 
// Shortcut from this release
$schedule->job(SyncSomething::class)->everyTwoHours();

Conditionally Return Appended Attributes in API Resources

Jess Archer contributed a whenAppended method for API resources to append attributes conditionally. Here are some examples taken from the contributed tests:

public function toArray($request)
{
return [
'id' => $this->id,
'first' => $this->whenAppended('is_published'),
'second' => $this->whenAppended('is_published', 'override value'),
'third' => $this->whenAppended('is_published', function () {
return 'override value';
}),
'fourth' => $this->whenAppended('is_published', $this->is_published, 'default'),
'fifth' => $this->whenAppended('is_published', $this->is_published, function () {
return 'default';
}),
];
}
 
// Controller Example
return new UserResource($user->append('is_subscribed'));

Scheduled Task Failed Event

Freek Van der Herten contributed a ScheduledTaskFailed event that fires when a scheduled task fails:

$this->dispatcher->dispatch(new ScheduledTaskFailed($event, $e));

Stringable when() Method

Manojkiran Appathurai contributed a Stringable::when() method to conditionally run some “stringable” code when true:

Str::of($blogContent)
->when(! Auth::check(), function ($stringable) {
return $stringable
->limit(20)
->append('To Continue reading ')
->append(new HtmlString(
'<a href="#">Get a Subscription</a>'
));
});

Release Notes

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

v7.19.0

Added

  • Added everyTwoHours() | everyThreeHours() | everyFourHours() | everySixHours() methods to Illuminate\Console\Scheduling\ManagesFrequencies (#33393)
  • Conditionally returning appended attributes in API resources (#33422)
  • Added ScheduledTaskFailed event (#33427)
  • Added Illuminate\Support\Stringable::when() (#33455)

Fixed

  • Fixed signed urls with custom parameters (bcb133e)
  • Determine model key name correctly in Illuminate/Validation/Concerns/ValidatesAttributes.php (a1fdd53)
  • Fixed notifications database channel for anonymous notifiables (#33409)

Changed

  • Improve SQL Server last insert id retrieval (#33430, de1d159)
  • Make Str::endsWith return false if both haystack and needle are empty strings (#33434)
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.

image
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech
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 $9500/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
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
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Shift logo

Shift

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

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
Lucky Media logo

Lucky Media

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

Lucky Media
Tinkerwell logo

Tinkerwell

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

Tinkerwell

The latest

View all →
Scheduler List: A Web Dashboard for Laravel's Scheduled Tasks image

Scheduler List: A Web Dashboard for Laravel's Scheduled Tasks

Read article
Community Laravel Extension for Zed image

Community Laravel Extension for Zed

Read article
Advanced Eloquent Query Filtering with Filterable image

Advanced Eloquent Query Filtering with Filterable

Read article
Bulk Job Dispatching with Bus::bulk() in Laravel 13.13 image

Bulk Job Dispatching with Bus::bulk() in Laravel 13.13

Read article
Audit Laravel Apps for Security Issues with Checkpoint image

Audit Laravel Apps for Security Issues with Checkpoint

Read article
In-Memory Eloquent Models with Truffle image

In-Memory Eloquent Models with Truffle

Read article