1. Go to this page and download the library: Download swarakaka/bridge-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
swarakaka / bridge-laravel example snippets
use Bridge\Bridge;
class CustomerController extends Controller
{
public function index(Request $request)
{
return Bridge::render('Customers/Index', [
'customers' => CustomerResource::collection(Customer::paginate(20)),
'filters' => ['search' => $request->string('search')->toString()],
'stats' => Bridge::defer(fn () => Customer::stats()), // loaded after first render
'filtersUi' => Bridge::lazy(fn () => Filter::all()), // only on partial reload
]);
}
public function store(StoreCustomerRequest $request)
{
$customer = Customer::create($request->validated());
return Bridge::redirect()
->route('customers.show', $customer)
->with('customer', CustomerResource::make($customer))
->flash('Customer created.')
->created();
}
}