Commenter
GitHubAdmin Panel
v2
v2
  • 😍Commenter
  • Overview
    • 💡Why Commenter
    • 🗞️Articles
    • ✨Key Features
    • 🤖Technologies
  • Basics
    • 🧠Concept
    • ®️Requirements
    • 🔨Installation
    • ✈️Usage
    • 🌈Themes
  • Demo
    • 👩‍🏫Project
    • 📺Basic Demo Video
    • 📼Full Demo Video
  • Configuration
    • 📜Publish Config
    • Migrations/Tables
    • ⚖️Change Mode
    • 🔐Authorization
    • ⏲️Limit comments per user
    • 😍Reactions
    • ⛔Approval
    • 🚧Validations
    • Sorting
    • 🛠️Other Options
  • Advance
    • 🔏Security
    • 🚀Performance
    • ⚡Events
    • 🌍Localization
    • 🛟Customization
    • 🕵️Testing
  • 🛣️Roadmap
  • 💓Sponsor
Powered by GitBook
On this page
  • Sorting Comments
  • Sorting Replies

Was this helpful?

Edit on GitHub
  1. Configuration

Sorting

PreviousValidationsNextOther Options

Last updated 7 months ago

Was this helpful?

Sorting Comments

Available Options: All the options in class.

  • Sort::TOP - Sort by custom algorithm (default).

  • Sort::LATEST - Sort by latest comments.

  • Sort::OLDEST - Sort by oldest comments.

  • Sort::REPLIES - Sort by replies count

Overwrite default sort order

Globally

Change the default_sort option in comments.config file.

// comments.config

use LakM\Comments\Enums\Sort;

return [
    // Default comments sort order, See Sort::class for available values
    'default_sort' => Sort::TOP,
];

Model-wise (Higher priority)

use Illuminate\Database\Eloquent\Model;
use LakM\Comments\Concerns\Commentable;
use LakM\Comments\Contracts\CommentableContract;
use LakM\Comments\Enums\Sort;

class Post extends Model implements CommentableContract
{
    use Commentable;

    $commmentsSortOrder = Sort::TOP;
}

Sorting Replies

  • Sort::LATEST - Sort by latest comments.

  • Sort::OLDEST - Sort by oldest comments.

Overwrite default sort order

Globally

Change the reply.default_sort option in comments.config file.

// comments.config

use LakM\Comments\Enums\Sort;

return [
    'reply' => [
        // Default comments sort order, available values: Sort::LATEST, Sort::OLDEST
        'default_sort' => Sort::LATEST,
    ],
];

Model-wise (Higher priority)

use Illuminate\Database\Eloquent\Model;
use LakM\Comments\Concerns\Commentable;
use LakM\Comments\Contracts\CommentableContract;
use LakM\Comments\Enums\Sort;

class Post extends Model implements CommentableContract
{
    use Commentable;

    $repliesSortOrder = Sort::TOP;
}

Define variable $commmentsSortOrder and set the value in model.

Available Options: Following options in class.

Define variable $repliesSortOrder and set the value in model.

LakM\Comments\Enums\Sort
LakM\Comments\Enums\Sort
commentable
commentable