Skip to content

Commit 4d8d8fd

Browse files
committed
Merge branch 'main' of github.com:parallax/filament-comments
2 parents 4385872 + b59b807 commit 4d8d8fd

File tree

7 files changed

+49
-5
lines changed

7 files changed

+49
-5
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"php": "^8.1",
2424
"filament/filament": "^3.0",
2525
"spatie/laravel-package-tools": "^1.15.0",
26-
"illuminate/contracts": "^10.0"
26+
"illuminate/contracts": "^10.0 | ^11.0"
2727
},
2828
"autoload": {
2929
"psr-4": {

config/filament-comments.php

+6
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,10 @@
5353
* Authenticatable model class
5454
*/
5555
'authenticatable' => \App\Models\User::class,
56+
57+
58+
/*
59+
* The name of the table where the comments are stored.
60+
*/
61+
'table_name' => 'filament_comments',
5662
];

database/migrations/add_index_to_subject.php.stub

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ return new class extends Migration
88
{
99
public function up(): void
1010
{
11-
Schema::table('filament_comments', function (Blueprint $table) {
11+
Schema::table(config('filament-comments.table_name', 'filament_comments'), function (Blueprint $table) {
1212
$table->index(['subject_type', 'subject_id']);
1313
});
1414
}
1515

1616
public function down(): void
1717
{
18-
Schema::table('filament_comments', function (Blueprint $table) {
18+
Schema::table(config('filament-comments.table_name', 'filament_comments'), function (Blueprint $table) {
1919
$table->dropIndex(['subject_type', 'subject_id']);
2020
});
2121
}

database/migrations/create_filament_comments_table.php.stub

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ return new class extends Migration
88
{
99
public function up()
1010
{
11-
Schema::create('filament_comments', function (Blueprint $table) {
11+
Schema::create(config('filament-comments.table_name', 'filament_comments'), function (Blueprint $table) {
1212
$table->id();
1313
$table->unsignedBigInteger('user_id');
1414
$table->string('subject_type');
@@ -21,6 +21,6 @@ return new class extends Migration
2121

2222
public function down()
2323
{
24-
Schema::dropIfExists('filament_comments');
24+
Schema::dropIfExists(config('filament-comments.table_name', 'filament_comments'));
2525
}
2626
};
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
return [
4+
'comments' => 'Kommentare',
5+
'comments.add' => 'Kommentar hinzufügen',
6+
'comments.empty' => 'Noch keine Kommentare.',
7+
'comments.placeholder' => 'Kommentar hinzufügen...',
8+
9+
'notifications.created' => 'Kommentar hinzugefügt.',
10+
'notifications.deleted' => 'Kommentar gelöscht.',
11+
12+
'modal.heading' => 'Kommentare',
13+
];
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
return [
4+
'comments' => 'Kommentarer',
5+
'comments.add' => 'Publiser kommentar',
6+
'comments.empty' => 'Ingen kommentarer enda.',
7+
'comments.placeholder' => 'Skriv en kommentar...',
8+
9+
'notifications.created' => 'Kommentar lagt til.',
10+
'notifications.deleted' => 'Kommentar slettet.',
11+
12+
'modal.heading' => 'Kommentarer',
13+
];

src/Models/FilamentComment.php

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Database\Eloquent\Model;
88
use Illuminate\Database\Eloquent\Relations\BelongsTo;
99
use Illuminate\Database\Eloquent\SoftDeletes;
10+
use Illuminate\Support\Facades\Config;
1011

1112
class FilamentComment extends Model
1213
{
@@ -20,6 +21,17 @@ class FilamentComment extends Model
2021
'comment',
2122
];
2223

24+
public function __construct(array $attributes = [])
25+
{
26+
$config = Config::get('filament-comments');
27+
28+
if (isset($config['table_name'])) {
29+
$this->setTable($config['table_name']);
30+
}
31+
32+
parent::__construct($attributes);
33+
}
34+
2335
public function user(): BelongsTo
2436
{
2537
$authenticatable = config('filament-comments.authenticatable');

0 commit comments

Comments
 (0)