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
  • Define global policies
  • Define authorization logic locally

Was this helpful?

Edit on GitHub
  1. Configuration

Authorization

PreviousChange ModeNextLimit comments per user

Last updated 7 months ago

Was this helpful?

All the policies used by the package globally are defined in the permission array. You are free to define your own .

Define global policies

// comments.php

 'permissions' => [
    'create-comment' => [CommentPolicy::class, 'create'],
    'update-comment' => [CommentPolicy::class, 'update'],
    'delete-comment' => [CommentPolicy::class, 'delete'],
    'create-reply' => [ReplyPolicy::class, 'create'],
    'update-reply' => [ReplyPolicy::class, 'update'],
    'delete-reply' => [ReplyPolicy::class, 'delete'],
    ],

Define authorization logic locally

You can define authorization logic model-wise using the following methods. These methods take priority for the relevant model, disregarding global policies.

use LakM\Comments\Concerns\Commentable;

class Post extends Model
{
    use Commentable;
    
    // Create comment
    public function commentCanCreate(): bool
    {
        return true;
    }
    
    // Edit comment
    public function commentCanEdit(): bool
    {
        return true;
    }
    
    // Delete comment
    public function commentCanDelete(): bool
    {
        return true;
    }
}
🔐
policies