PHPackages                             glebred/laravel-vue-simple-comments - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. glebred/laravel-vue-simple-comments

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

glebred/laravel-vue-simple-comments
===================================

Vue Laravel Inertia simple comments

v1.0.1(2y ago)114MITPHPPHP ^8.1

Since May 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/GlebRed/Laravel-Vue-Simple-Comments)[ Packagist](https://packagist.org/packages/glebred/laravel-vue-simple-comments)[ Docs](https://github.com/glebred/laravel-vue-simple-comments)[ RSS](/packages/glebred-laravel-vue-simple-comments/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Simple comments plugin for Laravel Inertia Vue stack
====================================================

[](#simple-comments-plugin-for-laravel-inertia-vue-stack)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3ecc6c7fe705c47d937176ebcf255cda5dc2b74c1c1ca7de4aaed3b010f0518b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676c65627265642f6c61726176656c2d7675652d73696d706c652d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/glebred/laravel-vue-simple-comments)[![Total Downloads](https://camo.githubusercontent.com/c6438ad1c2b60b152dbd37170037dd568de54811758c11308cb077b7b0feb009/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676c65627265642f6c61726176656c2d7675652d73696d706c652d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/glebred/laravel-vue-simple-comments)

### Preview

[](#preview)

[![preview](https://github.com/GlebRed/Laravel-Vue-Simple-Comments/raw/master/preview.gif)](https://github.com/GlebRed/Laravel-Vue-Simple-Comments/raw/master/preview.gif)

This package allows you to add comments to your Laravel Inertia Vue stack application. The comment form is implemented using TS and Daisy UI which is a kit of UI components for Tailwind CSS. I made it because I needed a simple comment form for my project. I hope it will be useful for you too.

Requirements
------------

[](#requirements)

- inertiajs/vue3
- Daisy UI,
- Tailwind
- Vue-toastification

```
npm i @inertiajs/inertia-vue3
npm i tailwindcss
npm i vue-toastification
npm i daisyui
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require glebred/laravel-vue-simple-comments
```

Publish the view

```
php artisan vendor:publish --provider="GlebRed\LaravelVueSimpleComments\LaravelVueSimpleCommentsServiceProvider"
```

This will create a

- Vue view: `resources/js/vendor/laravel-vue-simple-comments/Comments.vue`
- Also a migration `database/migrations/create_comments_table.php`
- Model `app/Models/Comment.php`
- Request `app/Http/Requests/CommentRequest.php`
- Resource `app/Http/Resources/CommentResource.php`

Call the comments section in your Vue component:

Import the component `import CommentForm from "@/vendor/laravel-vue-simple-comments/Comments.vue";`and use it in your template, for example:

```

```

Where `commentable` is the object you want to comment on, and `commentable_type` is the model name.

Usage
-----

[](#usage)

Implement abstact class LaravelVueSimpleComments in your controller. Here is an example:

```
use GlebRed\LaravelVueSimpleComments\Requests\CommentRequest;
use GlebRed\LaravelVueSimpleComments\LaravelVueSimpleComments;

class CommentsController extends LaravelVueSimpleComments
{

    public function store(CommentRequest $request)
    {
        $validated = $request->validated();

        $this->authorize('create', [Comment::class, $validated['commentable_id'], $validated['commentable_type']]);

        Comment::create([
            'commentable_id' => $validated['commentable_id'],
            'commentable_type' => $validated['commentable_type'],
            'user_id' => $request->user()->id,
            'body' => $validated['body'],
        ]);
        return back()->with('flash', [
            'message' => 'Comment added successfully!',
        ]);
    }

    public function destroy(Comment $comment)
    {
        $this->authorize('delete', $comment);

        $comment->delete();

        return back()->with('flash', [
            'message' => 'Comment deleted successfully!',
        ]);
    }
}
```

After that add routes to your web.php file:

```
