Laravel 12.26: Wayfinder in React & Vue Starter Kits + New Collection Methods
Laravel News•2 days ago•
950

Laravel 12.26: Wayfinder in React & Vue Starter Kits + New Collection Methods

Frameworks
laravel
react
vue
wayfinder
lazycollection
Share this content:

Summary:

  • Wayfinder integration in Laravel's React and Vue starter kits provides type-safe routing between backend and frontend.

  • New **withHeartbeat()** method for LazyCollection improves handling of long-running tasks.

  • Added **toPrettyJson()** method simplifies JSON formatting for better readability.

  • Numerous bug fixes and improvements across various components.

Laravel 12.26 Update: Enhanced React & Vue Integration and New Collection Features

The latest Laravel release (12.26.0) brings exciting improvements, particularly for developers using React and Vue.js.

Wayfinder Integration in Starter Kits

The Laravel React and Vue starter kits now include Wayfinder, a powerful tool that creates a type-safe bridge between your Laravel backend routes and your frontend applications. This ensures better code maintainability and reduces errors.

import { store, update } from "@/actions/App/Http/Controllers/PostController";

const Page = () => ( <form {...update.form.put(1)}> {/* <form action="/posts/1?_method=PUT" method="post"> /} {/ ... */} </form> );

New withHeartbeat() Method for LazyCollection

For long-running tasks, a new withHeartbeat() method has been added to LazyCollection. This allows you to execute a callback at regular intervals, preventing issues such as indefinite lock holds.

$lock = Cache::lock('generate-reports', CarbonInterval::minutes(5));
$lock->acquire();

Reports::where('status', 'pending') ->lazy() ->withHeartbeat(CarbonInterval::minutes(4), $lock->reacquire(...)) ->each($this->generateReport(...));

$lock->release();

Enhanced JSON Handling with toPrettyJson()

A new toPrettyJson() method has been added to various Laravel components (collections, models, etc.), providing a convenient way to format JSON output for better readability.

// Before
$collection = collect([1, 2, 3]);
$collection->toJson(JSON_PRETTY_PRINT);

// After $collection = collect([1, 2, 3]); $collection->toPrettyJson();

This update significantly enhances the developer experience, offering improvements in both Laravel's core functionality and its integration with popular JavaScript frameworks. For detailed release notes and a complete list of changes, check the official Laravel changelog.

Comments

0

Join Our Community

Sign up to share your thoughts, engage with others, and become part of our growing community.

No comments yet

Be the first to share your thoughts and start the conversation!

Newsletter

Subscribe our newsletter to receive our daily digested news

Join our newsletter and get the latest updates delivered straight to your inbox.

ReactRemoteJobs.com logo

ReactRemoteJobs.com

Get ReactRemoteJobs.com on your phone!