packagist inertiajs/inertia-laravel v0.6.0

latest releases: dev-async-requests, 1.x-dev, v1.3.0...
2 years ago

Automatic redirects

Since returning a Redirect::back() response is such a common pattern within an Inertia app, this adapter now does this automatically for you when no response is returned from a controller (#350).

For example, consider this teams controller which redirects back to the previous page after updating a team. With this new feature you can now omit the Redirect::back() response and it will happen automatically.

class TeamsController extends Controller
{
    public function update(Team $team)
    {
        $team->update(/* ... */);
-
-       return Redirect::back();
    }
}

You can disable this behavior, or even do something entirely different, by adding an onEmptyResponse method to your HandleInertiaRequests middleware:

use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * Determines what to do when an Inertia action returned with no response.
 * By default, we'll redirect the user back to where they came from.
 *
 * @param  Request  $request
 * @param  Response  $response
 * @return Response
 */
public function onEmptyResponse(Request $request, Response $response): Response
{
    // Use the default Laravel "empty" response
    return $response;
}

Fixed

  • Fixed namespace issue with Route::inertia() method (#368)
  • Added session check when sharing validation errors (#380)
  • Fixed docblock on facade render method (#387)

Don't miss a new inertia-laravel release

NewReleases is sending notifications on new releases.