Outsource Laravel Development Partner - $3200/Month | Bacancy

Append Artisan Tables with Laravel 6.15.0

Published on by

Append Artisan Tables with Laravel 6.15.0 image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

The Laravel team released v6.15.0 this week with support for appending tables in artisan commands, a validated authorization event, and a handler method you can override to customize HTTP exception views:

Validated Auth Event

A new validated auth even fires after the user is retrieved from the user provider and validated but before the Login event. Here’s the test verifying that Validated event was dispatched during an auth attempt:

use Illuminate\Auth\Events\Validated;
 
Event::assertDispatched(Validated::class, function ($event) {
$this->assertSame('web', $event->guard);
$this->assertEquals(1, $event->user->id);
 
return true;
});

Blueprint Supports Grammar Macros

Hafez Divandari contributed the ability for Blueprint to support Grammar macros when building raw SQL statements in the toSql() method. Grammar macros enable you to customize existing grammars.

I don’t have a good example, but here’s the updated condition in Blueprint::toSql() that will consider macros from grammar:

if (method_exists($grammar, $method) || $grammar::hasMacro($method)) {
if (!is_null($sql = $grammar->$method($this, $command, $connection))) {
$statements = array_merge($statements, (array) $sql);
}
}

Custom Exception Views

Maarten Buis contributed a “getHttpExceptionView()” method to the base exceptions Handler class. If you need some custom logic around getting the view used to render exceptions, you can override this method in the application Handler child class.

Here’s the framework’s handler implementation:

/**
* Get the view used to render HTTP exceptions.
*
* @param \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $e
* @return string
*/
protected function getHttpExceptionView(HttpExceptionInterface $e)
{
return "errors::{$e->getStatusCode()}";
}

Append Rows to an Artisan Table

You can append rows to tables in artisan commands using the appendRow method:

public function handle()
{
$table = $this->table(
['Column', 'Another column'],
[]
);
 
$table->appendRow(['Value', 'Another Value']);
$table->appendRow(['Value', 'Another Value']);
}

You can see the full list of new features and updates below and the whole diff between 6.14.0 and 6.15.0 on GitHub. The full release notes for Laravel 6.0 are available in the GitHub v6 changelog:

v6.15.0

Added

  • Added Illuminate\Auth\Events\Validated event (#31357, 7ddac28)
  • Make Blueprint support Grammar’s macro (#31365)
  • Added Macroable trait to Illuminate\Console\Scheduling\Schedule class (#31354)
  • Added support dispatchAfterResponse in BusFake (#31418, e59597f)
  • Added Illuminate\Foundation\Exceptions\Handler::getHttpExceptionView() (#31420)
  • Allowed appending of rows to Artisan tables (#31426)

Fixed

  • Fixed locks for sqlsrv queue (5868066)
  • Fixed Illuminate\Events\Dispatcher::hasListeners() (#31403, c80302e)
  • Fixed testing with unencrypted cookies (#31390)

Changed

  • Allowed multiple paths to be passed to migrate fresh and migrate refresh commands (#31381)
  • Split Console InteractsWithIO to external trait (#31376)
  • Added sms link as valid URL in UrlGenerator::isValid() method (#31382)
  • Upgrade CommonMark and use the bundled table extension (#31411)
  • Ensure Application::$terminatingCallbacks are reset on Application::flush() (#31413)
  • Remove serializer option in PhpRedisConnector::createClient() (#31417)
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
Laravel Cloud

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

Visit Laravel Cloud
Bacancy logo

Bacancy

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

Bacancy
Tinkerwell logo

Tinkerwell

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

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

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

PhpStorm
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
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
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
Lucky Media logo

Lucky Media

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

Lucky Media
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

The latest

View all →
Statamic 6 Is Officially Released image

Statamic 6 Is Officially Released

Read article
Livewire 4 and Blade Improvements in Laravel VS Code Extension v1.5.0 image

Livewire 4 and Blade Improvements in Laravel VS Code Extension v1.5.0

Read article
Manage PostgreSQL Databases Directly in VS Code with Microsoft's Extension image

Manage PostgreSQL Databases Directly in VS Code with Microsoft's Extension

Read article
NativePHP for Mobile Is Now Free image

NativePHP for Mobile Is Now Free

Read article
Fuse for Laravel: A Circuit Breaker Package for Queue Jobs image

Fuse for Laravel: A Circuit Breaker Package for Queue Jobs

Read article
Generate Complete Application Modules with a Single Command using Laravel TurboMaker image

Generate Complete Application Modules with a Single Command using Laravel TurboMaker

Read article