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

Was this helpful?

Edit on GitHub
  1. Configuration

Validations

All the validation rules can be found in the ValidationRules.php file located in the root directory.

Overwrite Validation Rules

You can define your own rules using the createCommentUsing(callable $callable) and updateCommentUsing(callable $callable) properties in the boot method of a service provider.

// AppServiceProvider.php

use LakM\Comments\ValidationRules;

public function boot()
{
    // Related commentable model will be injected to callable.
    ValidationRules::createCommentUsing(function (Model Post) {
        return [
            'guest_email' => [
                new RequiredIf($model->guestModeEnabled() && config('comments.guest_mode.email_enabled')),
                'nullable',
                'email',
                Rule::unique($commentTableName, 'guest_email')->ignore(request()->ip(), 'ip_address')
            ],
            'guest_name' => [
                new RequiredIf($model->guestModeEnabled()),
                Rule::unique($commentTableName, 'guest_name')->ignore(request()->ip(), 'ip_address')
            ],
            'text' => ['required'],
        ];
    })
}

PreviousApprovalNextSorting

Last updated 11 months ago

Was this helpful?

🚧