Skip to content

Commit 4d4bed1

Browse files
committed
Map polymorpic model
1 parent 89242aa commit 4d4bed1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

app/Models/Reply.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ final class Reply extends Model
1414
{
1515
use HasLikes, HasAuthor, HasTimestamps, ModelHelpers;
1616

17+
const TABLE = 'replies';
18+
1719
/**
1820
* {@inheritdoc}
1921
*/
20-
protected $table = 'replies';
22+
protected $table = self::TABLE;
2123

2224
/**
2325
* {@inheritdoc}

app/Providers/AppServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Providers;
44

5+
use App\Models\Reply;
56
use App\Models\Thread;
67
use Horizon;
78
use Illuminate\Database\Eloquent\Relations\Relation;
@@ -20,6 +21,7 @@ private function bootEloquentMorphs()
2021
{
2122
Relation::morphMap([
2223
Thread::TABLE => Thread::class,
24+
Reply::TABLE => Reply::class,
2325
]);
2426
}
2527

0 commit comments

Comments
 (0)