Looking to hire Laravel developers? Try LaraJobs

laravel-turbo maintained by johnnyfreeman

Description
Hotwire Turbo integration for Laravel.
Last update
2023/03/11 19:13 (dev-main)
License
Links
Downloads
3 683
Tags

Comments
comments powered by Disqus

Hotwire Turbo for Laravel

Some lightweight tools for sending Turbo Streams to the front end.

Installation

You can install the package via composer:

composer require johnnyfreeman/laravel-turbo

Usage

Controler

class PostCommentController
{
    public function store(Request $request, Post $post)
    {
        $comment = $post->comments()->create([
            'text' => $request->get('text')
        ]);

        if ($request->wantsTurboStream()) {
            return turbo_stream()
                ->prepend('comments', view('posts.comment', ['text' => $comment->text]))
                ->append('notifications', view('notifications.simple', ['title' => 'Post comment created!']));
        }

        return back();
    }
}

License

The MIT License (MIT). Please see License File for more information.