Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
The MIT License (MIT)

Copyright (c) coolsam <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Copyright (c) 2025 Hadi Alharbi
This package is developed based on the nested-comments package by Sam Maosa. Special thanks to Sam Maosa for their foundational work.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
440 changes: 56 additions & 384 deletions README.md

Large diffs are not rendered by default.

54 changes: 32 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,67 @@
{
"name": "coolsam/nested-comments",
"description": "Add Nested comments/replies to filament forms, infolists and resources",
"name": "hadialharbi/nested-comments",
"description": "Fork of coolsam/nested-comments with Arabic RTL support and Filament integration",
"keywords": [
"coolsam",
"nested-comments",
"laravel",
"nested-comments"
"filamentphp",
"livewire",
"rtl",
"arabic",
"comments"
],
"homepage": "https://github.com/coolsam/nested-comments",
"homepage": "https://github.com/hadialharbi2020/nested-comments",
"support": {
"issues": "https://github.com/coolsam/nested-comments/issues",
"source": "https://github.com/coolsam/nested-comments"
"issues": "https://github.com/hadialharbi2020/nested-comments/issues",
"source": "https://github.com/hadialharbi2020/nested-comments"
},
"license": "MIT",
"authors": [
{
"name": "Sam Maosa",
"email": "[email protected]",
"role": "Developer"
}
],
{
"name": "Hadi Al-Harbi",
"email": "[email protected]",
"role": "Maintainer"
},
{
"name": "Sam Maosa",
"email": "[email protected]",
"role": "Original Developer"
}
],
"require": {
"php": "^8.2",
"awcodes/filament-tiptap-editor": "^3.5.12",
"filament/filament": "^3.2",
"kalnoy/nestedset": "^6.0.5",
"illuminate/translation": "*",
"kalnoy/nestedset": "^6.0",
"spatie/laravel-package-tools": "^1.15.0",
"tangodev-it/filament-emoji-picker": "^1.0.3"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^3.5",
"laravel/pint": "^1.0",
"livewire/livewire": "^3.6",
"nunomaduro/larastan": "^3.1.0",
"orchestra/testbench": "^9.12",
"pestphp/pest-plugin-laravel": "^3.1",
"orchestra/testbench": "^10.4",
"pestphp/pest-plugin-livewire": "^3.0",
"phpstan/extension-installer": "^1.4.3",
"spatie/laravel-ray": "^1.39"
},
"autoload": {
"psr-4": {
"Coolsam\\NestedComments\\": "src/",
"Coolsam\\NestedComments\\Database\\Factories\\": "database/factories/"
"Hadialharbi\\NestedComments\\": "src/",
"Hadialharbi\\NestedComments\\Database\\Factories\\": "database/factories/"
}
},
"autoload-dev": {
"psr-4": {
"Coolsam\\NestedComments\\Tests\\": "tests/"
"Hadialharbi\\NestedComments\\Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test": "phpunit",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
},
Expand All @@ -65,10 +75,10 @@
"extra": {
"laravel": {
"providers": [
"Coolsam\\NestedComments\\NestedCommentsServiceProvider"
"Hadialharbi\\NestedComments\\NestedCommentsServiceProvider"
],
"aliases": {
"NestedComments": "Coolsam\\NestedComments\\Facades\\NestedComments"
"NestedComments": "Hadialharbi\\NestedComments\\Facades\\NestedComments"
}
}
},
Expand Down
66 changes: 37 additions & 29 deletions config/nested-comments.php
Original file line number Diff line number Diff line change
@@ -1,56 +1,64 @@
<?php

use Illuminate\Database\Eloquent\Model;

return [

'tables' => [
'comments' => 'comments',
'reactions' => 'reactions',
'users' => 'users', // The table that will be used to get the authenticated user
'users' => 'users',
],

'models' => [
'comment' => \Coolsam\NestedComments\Models\Comment::class,
'reaction' => \Coolsam\NestedComments\Models\Reaction::class,
'user' => env('AUTH_MODEL', 'App\Models\User'), // The model that will be used to get the authenticated user
'comment' => Hadialharbi\NestedComments\Models\Comment::class,
'reaction' => Hadialharbi\NestedComments\Models\Reaction::class,
'user' => env('AUTH_MODEL', App\Models\User::class),
],

'policies' => [
'comment' => null,
'reaction' => null,
],

'allowed-reactions' => [
'👍' => 'thumbs up', // thumbs up
'👎' => 'thumbs down', // thumbs down
'❤️' => 'heart', // heart
'😂' => 'laughing', // laughing
'😮' => 'surprised', // surprised
'😢' => 'crying', // crying
'💯' => 'hundred points', // angry
'🔥' => 'fire', // fire
'🎉' => 'party popper', // party popper
'🚀' => 'rocket', // rocket
'👍' => 'thumbs up',
'👎' => 'thumbs down',
'❤️' => 'heart',
'😂' => 'laughing',
'😮' => 'surprised',
'😢' => 'crying',
'💯' => 'hundred points',
'🔥' => 'fire',
'🎉' => 'party popper',
'🚀' => 'rocket',
],
'allow-all-reactions' => env('ALLOW_ALL_REACTIONS', false), // Allow any other emoji apart from the ones listed above
'allow-multiple-reactions' => env('ALLOW_MULTIPLE_REACTIONS', false), // Allow multiple reactions from the same user
'allow-guest-reactions' => env('ALLOW_GUEST_REACTIONS', false), // Allow guest users to react
'allow-guest-comments' => env('ALLOW_GUEST_COMMENTS', false), // Allow guest users to comment

'allow-all-reactions' => env('ALLOW_ALL_REACTIONS', false),
'allow-multiple-reactions' => env('ALLOW_MULTIPLE_REACTIONS', false),
'allow-guest-reactions' => env('ALLOW_GUEST_REACTIONS', false),
'allow-guest-comments' => env('ALLOW_GUEST_COMMENTS', false),

'format-created-date' => 'F j Y h:i:s A',
/*
|--------------------------------------------------------------------------
| Livewire Component
|--------------------------------------------------------------------------
|
*/
'show-heading' => true,

'show-heading' => true,
'show-badge-counter' => true,
'badge-counter-color' => 'info',

'show-refresh-button' => true,
'style-refresh-button' => 'button', // 'button' or 'icon',
'style-refresh-button' => 'button',
'icon-refresh-button' => 'heroicon-m-sparkles',
'outlined-refresh-button' => false,
'color-refresh-button' => 'info' // 'danger', 'gray', 'info', 'success' or 'warning'
'color-refresh-button' => 'info',

// 🆕 إضافات مقترحة مستقبلًا:
'enable_rtl' => true,

'ui' => [
'show_user_avatar' => true,
'show_datetime_tooltip' => true,
],

'permissions' => [
'can_edit_comment' => true,
'can_delete_comment' => true,
],
];
2 changes: 1 addition & 1 deletion database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Coolsam\NestedComments\Database\Factories;
namespace Hadialharbi\NestedComments\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::create('comments', function (Blueprint $table) {
$table->id();
$table->nestedSet();
$table->foreignId('user_id')->nullable()->constrained('users')->cascadeOnDelete();
$table->text('body');
$table->morphs('commentable');
$table->ulid('guest_id')->nullable()->index();
$table->string('guest_name')->nullable();
$table->ipAddress()->nullable();
$table->boolean('is_published')->default(false);
$table->timestamps();
});

Schema::create('reactions', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained('users')->cascadeOnDelete();
$table->morphs('reactable');
$table->string('emoji');
$table->ulid('guest_id')->nullable()->index();
$table->string('guest_name')->nullable();
$table->ipAddress()->nullable();
$table->boolean('is_published')->default(false);
$table->timestamps();
});
}

public function down(): void
{
Schema::dropIfExists('reactions');
Schema::dropIfExists('comments');
}
};
Empty file added fix-namespace.sh
Empty file.
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ parameters:
- config
- database
ignoreErrors:
- '#Trait Coolsam\\NestedComments\\Concerns\\HasComments is used zero times and is not analysed#'
- '#Trait Hadialharbi\\NestedComments\\Concerns\\HasComments is used zero times and is not analysed#'
-
message: "#Called 'env' outside of the config directory which returns null when the config is cached, use 'config'#"
path: config/*
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Coolsam Test Suite">
<testsuite name="Hadialharbi Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
13 changes: 10 additions & 3 deletions resources/css/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
@import '../../vendor/filament/filament/resources/css/theme.css';
@import '../../vendor/awcodes/filament-tiptap-editor/resources/css/plugin.css';

.comment-mention, [data-mention-id] {
@apply bg-primary-50 !text-primary-500 dark:bg-gray-700 dark:text-primary-50 dark:border-primary-500 p-1 rounded-full px-2 before:content-["@"];
}
.comment-mention:dir(rtl),
[data-mention-id]:dir(rtl) {
@apply rounded-full p-1 px-2 text-primary-500 bg-primary-50 dark:bg-gray-700 dark:text-primary-50 dark:border-primary-500;
direction: rtl;
}

.comment-mention:dir(rtl)::before,
[data-mention-id]:dir(rtl)::before {
content: "@"; /* أو "@" بالعربي إذا حبيت */
}
68 changes: 68 additions & 0 deletions resources/lang/ar/nested-comments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

// translations for Hadialharbi/NestedComments
return [
'comments' => [
'general' => [
'guest' => 'زائر',
'no_comments_provided' => 'لا توجد تعليقات.',
'no_commentable_record_set' => 'لم يتم تعيين سجل قابل للتعليق.',
'record_is_not_configured_for_reactions' => 'السجل الحالي غير مهيأ للتفاعلات. يرجى تضمين الـ Trait المسمى `HasReactions` في النموذج.',
'no_commentable_record_found_widget' => 'لم يتم العثور على سجل قابل للتعليق. يرجى تمرير سجل إلى الودجت.',
'reply' => 'رد',
'no_replies' => 'لا توجد ردود بعد.',
'comments' => 'التعليقات',
],
'form' => [
'field' => [
'comment' => [
'label' => 'تعليقك',
'mention_items_placeholder' => 'ابحث عن المستخدمين بالاسم أو البريد الإلكتروني',
'empty_mention_items_message' => 'لم يتم العثور على مستخدمين',
],
],
'buttons' => [
'submit' => 'إرسال',
'cancel' => 'إلغاء',
'add_comment' => 'إضافة تعليق جديد',
'add_reply' => 'إضافة رد',
'reply' => 'رد',
'hide_replies' => 'إخفاء الردود',
'refresh' => 'تحديث',
],
],
'table' => [
'actions' => [
'view_comments' => [
// 'label' => 'عرض التعليق',
'heading' => 'التعليقات',
'close' => 'إغلاق',
],
],
],
'actions' => [
'view_comment' => [
// 'label' => 'عرض التعليق',
'heading' => 'عرض التعليقات',
'close' => 'إغلاق',
],
],
],
'reactions' => [
'add_reaction' => 'أضف تفاعلًا',

// يمكنك ترجمة الرموز التعبيرية (emoji) أيضًا إن رغبت

'👍' => 'إعجاب',
'👎' => 'عدم إعجاب',
'❤️' => 'إعجاب قوي',
'😂' => 'مضحك',
'😮' => 'مندهش',
'😢' => 'محزن',
'💯' => 'ممتاز',
'🔥' => 'ناري',
'🎉' => 'احتفال',
'🚀' => 'إطلاق',
],

];
Loading