All Projects β†’ laravelista β†’ Comments

laravelista / Comments

Licence: mit
Native comments for your Laravel application.

Projects that are alternatives of or similar to Comments

Artisan View
πŸ‘€ Manage your views in Laravel projects through artisan
Stars: ✭ 708 (+81.54%)
Mutual labels:  hacktoberfest, laravel, package, blade
Laravel Acl
This package helps you to associate users with permissions and permission groups with laravel framework
Stars: ✭ 404 (+3.59%)
Mutual labels:  hacktoberfest, laravel, package
Blogetc
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.
Stars: ✭ 198 (-49.23%)
Mutual labels:  laravel, package, blade
Laravel Packager
A cli tool for creating Laravel packages
Stars: ✭ 1,049 (+168.97%)
Mutual labels:  hacktoberfest, laravel, package
Jigsaw
Simple static sites with Laravel’s Blade.
Stars: ✭ 1,823 (+367.44%)
Mutual labels:  hacktoberfest, laravel, blade
Laravel Disqus
A simple Disqus platform integration with Laravel.
Stars: ✭ 71 (-81.79%)
Mutual labels:  hacktoberfest, comments, laravel
Laravel Translatable
A Laravel package for multilingual models
Stars: ✭ 624 (+60%)
Mutual labels:  hacktoberfest, laravel, package
Nebula
Nebula is a minimalistic and easy to use administration tool for Laravel applications, made with Laravel, Alpine.js, and Tailwind CSS.
Stars: ✭ 190 (-51.28%)
Mutual labels:  hacktoberfest, laravel, package
Laravel Totem
Manage Your Laravel Schedule From A Web Dashboard
Stars: ✭ 1,299 (+233.08%)
Mutual labels:  hacktoberfest, laravel, package
Laravel Package Maker
Get a πŸ“¦ skeleton and all other `make` commands from laravel base for package development.
Stars: ✭ 89 (-77.18%)
Mutual labels:  hacktoberfest, laravel, package
Laravel Messenger
Simple user messaging package for Laravel
Stars: ✭ 2,140 (+448.72%)
Mutual labels:  hacktoberfest, laravel, package
Laravelpackage.com
Documentation for LaravelPackage.com: Learn to create Laravel specific PHP packages from scratch, following this open documentation.
Stars: ✭ 214 (-45.13%)
Mutual labels:  hacktoberfest, laravel, package
Themevel
Theme and asset management for laravel
Stars: ✭ 278 (-28.72%)
Mutual labels:  laravel, blade
Spatie.be
The source code of spatie.be
Stars: ✭ 274 (-29.74%)
Mutual labels:  hacktoberfest, laravel
Short Url
A Laravel package for creating shortened URLs for your web apps.
Stars: ✭ 293 (-24.87%)
Mutual labels:  hacktoberfest, laravel
Providers
A Collection of Providers for Laravel Socialite
Stars: ✭ 301 (-22.82%)
Mutual labels:  hacktoberfest, laravel
Tlint
Tighten linter for Laravel conventions
Stars: ✭ 274 (-29.74%)
Mutual labels:  hacktoberfest, laravel
Laravel Api Boilerplate
Laravel API Boilerplate | Please consult the Wiki !
Stars: ✭ 300 (-23.08%)
Mutual labels:  hacktoberfest, laravel
Laravel Starter
A CMS like modular starter application project built with Laravel 8.x.
Stars: ✭ 299 (-23.33%)
Mutual labels:  hacktoberfest, laravel
Finance
A self hosted app to help you get a better understanding of your personal finances.
Stars: ✭ 313 (-19.74%)
Mutual labels:  hacktoberfest, laravel

Comments

Comments is a Laravel package. With it you can easily implement native comments for your application.

Become a Patron

Overview

This package can be used to comment on any model you have in your application.

All comments are stored in a single table with a polymorphic relation for content and a polymorphic relation for the user who posted the comment.

Features

  • View comments
  • Create comments
  • Delete comments
  • Edit comments
  • Reply to comments
  • Authorization rules
  • Support localization
  • Dispatch events
  • Route, Controller, Comment, Migration & View customizations
  • Support for non-integer IDs
  • Support for multiple User models
  • Solved N+1 query problem
  • Comment approval (opt-in)
  • Guest commenting (opt-in)
  • Pagination (opt-in)
  • Soft deletes (opt-in)
  • Works with custom ID columns
  • Optionally load package migrations [NEW]
  • Configure maximum indentation level [NEW]

Screenshots

Here are a few screenshots.

No comments & guest:

No comments & logged in:

One comment:

One comment edit form:

Two comments from different users:

Tutorials & articles

I plan to expand this chapter with more tutorials and articles. If you write something about this package let me know, so that I can update this chapter.

Screencasts:

Installation

From the command line:

composer require laravelista/comments

Run migrations

We need to create the table for comments.

php artisan migrate

Add Commenter trait to your User model

Add the Commenter trait to your User model so that you can retrieve the comments for a user:

use Laravelista\Comments\Commenter;

class User extends Authenticatable
{
    use Notifiable, Commenter;
}

Add Commentable trait to models

Add the Commentable trait to the model for which you want to enable comments for:

use Laravelista\Comments\Commentable;

class Product extends Model
{
    use Commentable;
}

Publish Config & configure (optional)

Publish the config file (optional):

php artisan vendor:publish --provider="Laravelista\Comments\ServiceProvider" --tag=config

Publish views (customization)

The default UI is made for Bootstrap 4, but you can change it however you want.

php artisan vendor:publish --provider="Laravelista\Comments\ServiceProvider" --tag=views

Publish Migrations (customization)

You can publish migration to allow you to have more control over your table

php artisan vendor:publish --provider="Laravelista\Comments\ServiceProvider" --tag=migrations

Publish translations (customization)

The package currently only supports English, but I am open to PRs for other languages.

php artisan vendor:publish --provider="Laravelista\Comments\ServiceProvider" --tag=translations

Usage

In the view where you want to display comments, place this code and modify it:

@comments(['model' => $book])

In the example above we are setting the commentable_type to the class of the book. We are also passing the commentable_id the id of the book so that we know to which book the comments relate to. Behind the scenes, the package detects the currently logged in user if any.

If you open the page containing the view where you have placed the above code, you should see a working comments form.

View only approved comments

To view only approved comments, use this code:

@comments([
    'model' => $book,
    'approved' => true
])

Paginate comments

Pagination paginates by top level comments only, meaning that if you specify the number of comments per page to be 1, and that one comment has 100 replies, it will display that one comment and all of its replies.

It was not possible to do it any other way, because if I paginate by all comments (parent and child) you will end up with blank pages since the comments components loops parent comments first and then uses recursion for replies.

To use pagination, use this code:

@comments([
    'model' => $user,
    'perPage' => 2
])

Replace 2 with any number you want.

Configure maximum indentation level

By default the replies go up to level three. After that they are "mashed" at that level.

- 0
    - 1
        - 2
            - 3

You can configure the maximum indentation level like so:

@comments([
    'model' => $user,
    'maxIndentationLevel' => 1
])

Events

This package fires events to let you know when things happen.

  • Laravelista\Comments\Events\CommentCreated
  • Laravelista\Comments\Events\CommentUpdated
  • Laravelista\Comments\Events\CommentDeleted

REST API

To change the controller or the routes, see the config.

Route::post('comments', '\Laravelista\Comments\[email protected]');
Route::delete('comments/{comment}', '\Laravelista\Comments\[email protected]');
Route::put('comments/{comment}', '\Laravelista\Comments\[email protected]');
Route::post('comments/{comment}', '\Laravelista\Comments\[email protected]');

POST /comments

Request data:

'commentable_type' => 'required|string',
'commentable_id' => 'required|string|min:1',
'message' => 'required|string'

PUT /comments/{comment}

  • {comment} - Comment ID.

Request data:

'message' => 'required|string'

POST /comments/{comment}

  • {comment} - Comment ID.

Request data:

'message' => 'required|string'

Upgrading from older versions (troubleshoot)

Before creating an issue, read this.

Sponsors & Backers

I would like to extend my thanks to the following sponsors & backers for funding my open-source journey. If you are interested in becoming a sponsor or backer, please visit the Backers page.

Contributing

Thank you for considering contributing to Comments! The contribution guide can be found Here.

Code of Conduct

In order to ensure that the open-source community is welcoming to all, please review and abide by the Code of Conduct.

License

Comments is open-source software licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].