Admin panel for the commenter
Description | Requirements | Installation | Usage | Config | Authoriztion | Models Discovery | Route | Customization | Changelog | Security | License
Provides an ideal admin panel to manage the Commenter package.
![](https://private-user-images.githubusercontent.com/47297673/339323741-49bc9302-abe1-488e-a035-1c8571dfeae7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMjY1OTMsIm5iZiI6MTcyNDEyNjI5MywicGF0aCI6Ii80NzI5NzY3My8zMzkzMjM3NDEtNDliYzkzMDItYWJlMS00ODhlLWEwMzUtMWM4NTcxZGZlYWU3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIwVDAzNTgxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI2NGZhNGU4ZWM1Y2YwMjBiMzM0Y2FmMmFmZDhjNjkxOTdjNmVmZjUzY2ZlYjg2ZjEyODhkYjZlODJiMWQ5MGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.gF_sWnc7RqUco4amL4HbVRo2Ysvk-_-MGuP4VRMVOIc)
- PHP : ^8.1 | ^8.2 | ^8.3
- laravel/framework : ^ 10.0 | ^11.0
- lakm/laravel-comments : *
- filament/notifications : ^3.2
- filament/tables : ^3.2
composer require lakm/laravel-comments-admin-panel -W
php artisan commenter-admin-panel:install
Optional
You can publish views using below command.
php artisan vendor:publish --tag=comments-admin-panel-resources
All you need to do is navigate to the package's default route end point /admin/comments/dashboard
Config file is published as comments-admin-panel.php
in the config directory.
If it is missing, you can re-publish it using the command below.
php artisan vendor:publish --tag=comments-admin-panel-config
This will publish following config file
//config/comments-admin-panel.php
<?php
use LakM\Comments\AdminPanel\Middleware\AdminPanelAccessMiddleware;
return [
'enabled' => true,
'routes' => [
'middlewares' => [
'web',
AdminPanelAccessMiddleware::class, // Removing this, allow users to access admin panel if enabled is set to true !
],
'prefix' => 'admin',
],
/**
* Commentable models(must implement CommentableContract) that the admin panel must track
* Keep empty to use models auto-discovery
*/
'commentable_models' => [],
];
By default, routes are enabled if it is not in production environment. You can change this behaviour by setting enabled variable to false in the config file.
'enabled' => false
Before deploying to production (in production mode), the canAccessAdminPanel
method must be implemented in the auth
model; otherwise, you will receive a 404 status. This behaviour is handled by the AdminPanelAccessMiddleware::class
middleware.
//config/comments-admin-panel.php
public function canAccessAdminPanel(): bool
{
return true;
}
Note
Don't forget to set 'enabled' => true
in the config file.
By default, package scan all the commentable models in App/Models
namespace. You can change this
behaviour by explicitly defining models you want admin panel to track.
//config/comments-admin-panel.php
return [
'commentable_models' => [Post::class], // Admin panel only track for post class
]
You can access to the admin panel visiting default route end point /admin/comments/dashboard
By default, admin prefix is added to package's routes you can change it as following example.
'routes' => ['prefix' => 'admin'],
By default, web
and AdminPanelAccessMiddleware::class
middlewares are applied you can change it as following example.
'routes' => [
'middlewares' => [
'web',
AdminPanelAccessMiddleware::class, // Removing this, allow users to access admin panel if enabled is set to true !
],
],
You can customize all the views by publishing them using below commands,
php artisan vendor:publish --tag=comments-admin-panel-resources
This will publish views to the \resources\views\comments-admin-panel
directory.
Package's install command comments-admin-panel:install
, publish assets to the \public\vendor\lakm\comments-admin-panel
directory.
Here is the command to publish them manually.
php artisan vendor:publish --tag=comments-admin-panel-assets
You can build assets using any assets building tool. By default, package has used laravel vite plugin.
Make sure to use right build directory public\vendor\lakm\comments-admin-panel\build
Important
When building assets the re should be only one input file and that is should be app.js
.
You can do that as following using vite.
// vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
hotFile: 'public/vendor/lakm/comments-admin-panel/comments-admin-panel.hot',
buildDirectory: 'vendor/lakm/comments-admin-panel/build', // This is important
input: ['resources/js/app.js'], // This is important
refresh: true,
}),
],
});
Please see CHANGELOG for more information what has changed recently.
Please see here for our security policy.
The MIT License (MIT). Please see License File for more information.