This pull request adds the render functio, and it allows to hook into the request to add custom data, specify fragments, etc. This is very powerful because we can even return a different response.
Here is an example, where we are performing validation using the get function, and adding additional data to the view:
<?php
use function Laravel\Folio\render;
render(function (View $view, User $user) {
if (! Gate::check('view', $user)) {
return to_route('users.index');
}
return $view->with('posts', $user->posts);
})->name('users.show') ?>
<div>
<!-- Template here. This available variables are: $user and $posts now... -->
</div>
Fixes https://github.com/laravel/folio/issues/99.
This pull request adds the
render
functio, and it allows to hook into the request to add custom data, specify fragments, etc. This is very powerful because we can even return a different response.Here is an example, where we are performing validation using the
get
function, and adding additional data to the view: