The Laravel team released v6.15.0 with support for appending tables in artisan commands, a validated authorization event, and a handler method you can override to customize HTTP exception views:
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;
}
);
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);
}
}
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()}";
}
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:
Illuminate\Auth\Events\Validated
event (#31357, 7ddac28)Blueprint
support Grammar’s macro
(#31365)Macroable
trait to Illuminate\Console\Scheduling\Schedule
class (#31354)dispatchAfterResponse
in BusFake
(#31418, e59597f)Illuminate\Foundation\Exceptions\Handler::getHttpExceptionView()
(#31420)locks
for sqlsrv
queue (5868066)Illuminate\Events\Dispatcher::hasListeners()
(#31403, c80302e)UrlGenerator::isValid()
method (#31382)Application::$terminatingCallbacks
are reset on Application::flush()
(#31413)PhpRedisConnector::createClient()
(#31417)#laravel #php