Skip to content

Commit 731fe44

Browse files
Update create_commentions_reactions_table.php.stub (#46)
* Update create_commentions_reactions_table.php.stub * Update Config
1 parent 451389d commit 731fe44

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

database/migrations/create_commentions_reactions_table.php.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ return new class extends Migration
1010
{
1111
Schema::create(config('commentions.tables.comment_reactions', 'comment_reactions'), function (Blueprint $table) {
1212
$table->id();
13-
$table->foreignId('comment_id')->constrained(config('commentions.table_name'))->cascadeOnDelete();
13+
$table->foreignId('comment_id')->constrained(config('commentions.tables.comments'))->cascadeOnDelete();
1414
$table->morphs('reactor');
1515

1616
if (config('database.default') === 'mysql') {

src/Comment.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class Comment extends Model implements RenderableComment
4141
'author_id',
4242
];
4343

44+
public function getTable()
45+
{
46+
return Config::getCommentTable();
47+
}
48+
4449
public function author(): MorphTo
4550
{
4651
return $this->morphTo();

src/CommentReaction.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class CommentReaction extends Model
2020
'reaction',
2121
];
2222

23+
public function getTable()
24+
{
25+
return Config::getCommentReactionTable();
26+
}
27+
2328
/** @return BelongsTo<Comment> */
2429
public function comment(): BelongsTo
2530
{

src/Config.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ public static function resolveAuthenticatedUser(): ?Commenter
2929
return $user;
3030
}
3131

32+
public static function getCommentTable(): string
33+
{
34+
return config('commentions.tables.comments', 'comments');
35+
}
36+
37+
public static function getCommentReactionTable(): string
38+
{
39+
return config('commentions.tables.comment_reactions', 'comment_reactions');
40+
}
41+
3242
public static function getCommentModel(): string
3343
{
3444
return config('commentions.comment.model', Comment::class);

0 commit comments

Comments
 (0)