Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
vigstudio committed Dec 24, 2022
1 parent 40ef921 commit 25bd40d
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 15 deletions.
108 changes: 107 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@
- [x] Add comments to any model
- [x] Multiple comment systems on the same page
- [x] Multiple auth guards
- [x] Drag and drop, copy and paste upload files
- [x] Image and File upload support
- [x] Drag and drop, copy and paste upload files support
- [x] reCaptcha v3 support
- [x] Emoji support
- [x] Markdown support
- [x] NSFW image upload check support

## _Pending Features_
- [ ] Allow guest to comment
- [ ] Admin panel
- [ ] Mention user with @
- [ ] Emoji Suggestion Popup
- [ ] Delete Report comment
- [ ] Ratting system
- [ ] Toolbar for comment
- [ ] Comment history
- [ ] Show Nested comments
- [ ] Unit test

## _Packages_
- [Livewire](https://laravel-livewire.com/docs/2.x/installation)
- [AlpineJs](https://alpinejs.dev/essentials/installation)
Expand Down Expand Up @@ -58,6 +71,99 @@ php artisan vendor:publish --tag=vgcomment-assets-livewire
```bash
php artisan vendor:publish --tag=vgcomment-config
```
Edit prefix route in `config/vgcomment.php` file.
```php
/*
|--------------------------------------------------------------------------
| Route Prefix
|--------------------------------------------------------------------------
|
| This is the URI path where VgComment will be accessible from. Feel free to
| change this path to anything you like.
|
*/
'prefix' => 'vgcomment',
```

Edit connection name in `config/vgcomment.php` file.
```php
/*
|--------------------------------------------------------------------------
| Database Connection
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all of your database work.
|
*/
'connection' => env('DB_CONNECTION', 'mysql'),
```

Edit table names in `config/vgcomment.php` file.

```php
/*
|--------------------------------------------------------------------------
| Name of Tables in Database
|--------------------------------------------------------------------------
|
| This is the name of the table that will be created by the migration and
| used by the Comment model shipped with this package.
|
| "comments" : Comments Table
| "files" : Files Attachment Table
| "reactions" : Reactions Table
| "reports" : Reports Table
| "settings" : Settings Table
|
*/
'table' => [
'comments' => 'vgcomments',
'files' => 'vgcomment_files',
'reactions' => 'vgcomment_reactions',
'reports' => 'vgcomment_reports',
'settings' => 'vgcomment_settings',
],
```

Config Column or Attribute User Model in `config/vgcomment.php` file.
```php
/*
|--------------------------------------------------------------------------
| Column of User Table for get Data
|--------------------------------------------------------------------------
|
| This is the setting for column of user table for get data.
| "user_column_name" : Column name for get name user
| "user_column_email" : Column name for get email user
| "user_column_url" : Column name for get url user
|
*/
'user_column_name' => 'name',
'user_column_email' => 'email',
'user_column_url' => 'url',
'user_column_avatar_url' => 'avatar_url',
```

Set moderation user in `config/vgcomment.php` file.
```php
/*
|--------------------------------------------------------------------------
| Users Manager Comments
|--------------------------------------------------------------------------
|
| This is the setting for users manager comments.
| 'guard' => [user_id]
|
| Example:
| 'web' => [1, 2, 3]
| 'api' => [1, 2, 3]
|
*/
'moderation_users' => [
'web' => [1],
],
```

**Run the migrate command to create the necessary tables:**
Before running the migrate command, you can edit the `config/vgcomment.php` file to change the table names.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"homepage": "https://github.com/vigstudio/livewire-comments",
"license": "MIT",
"type": "laravel-library",
"version": "1.0.3",
"version": "1.0.4",
"authors": [
{
"name": "Nghiane.com",
Expand Down
2 changes: 1 addition & 1 deletion public/css/comments.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/views/components/comment.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class="vcomment-row @if ($replies) children @endif"
<div class="author">
<div class="avatar">
<img class="avatar__image"
src="{{ $comment->avatar_url }}"
src="{{ $comment->author_avatar }}"
alt="{{ $comment->author_name }}">
{{-- <span class="avatar--badge">Admin</span> --}}
</div>
Expand Down
35 changes: 24 additions & 11 deletions resources/views/livewire/comments.blade.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
<div class="vcomments-box">

<x-livewire-comments::modal />
<x-livewire-comments::alert />
<x-livewire-comments::confirm />
<div class="flex justify-between items-center mb-6 border-b-2 border-gray-400 px-4">
<h2 class="text-lg lg:text-2xl font-bold text-gray-900">
{{ __('vgcomment::comment.discussion') }} ({{ $this->comments->total() }})
</h2>

<livewire:livewire-comments::form
method="submit"
:pageId="$pageId"
:commentable="$commentable" />
<div class="flex justify-between items-center mb-2">
<div class="flex justify-between">
<select wire:model="request.order" class="mt-1 block w-full rounded-md border-gray-300 py-2 pl-3 pr-10 text-base focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm">
<option value="latest">{{ __('vgcomment::comment.latest') }}</option>
<option value="oldest">{{ __('vgcomment::comment.oldest') }}</option>
<option value="popular">{{ __('vgcomment::comment.popular') }}</option>
</select>
</div>
</div>
</div>

<livewire:livewire-comments::form method="submit" :pageId="$pageId" :commentable="$commentable" />

@foreach ($this->comments as $comment)
<x-livewire-comments::comment :comment="$comment" />

@foreach ($comment->replies as $replies)
<x-livewire-comments::comment
:key="$replies->uuid"
:replies="true"
:comment="$replies" />
<x-livewire-comments::comment :key="$replies->uuid" :replies="true" :comment="$replies" />
@endforeach
@endforeach

<div>
{{ $this->comments->links() }}
</div>


<x-livewire-comments::modal />
<x-livewire-comments::alert />
<x-livewire-comments::confirm />


<script src="https://www.google.com/recaptcha/api.js?render={{ Config::get('vgcomment.recaptcha_key') }}"></script>
</div>
1 change: 1 addition & 0 deletions src/Http/Livewire/CommentsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CommentsComponent extends Component
'page_id' => null,
'commentable_type' => null,
'commentable_id' => null,
'order' => 'latest',
];

protected $queryString = [];
Expand Down

0 comments on commit 25bd40d

Please sign in to comment.