From 1f9a344f33e158edf6aa3283d2e81c7670d30339 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 24 May 2023 15:12:35 +0200 Subject: [PATCH] Make the (Scoped)Comment model distinction clearer --- tests/Etc/Comment.php | 5 +++++ tests/Etc/Post.php | 3 ++- tests/Etc/ScopedComment.php | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Etc/Comment.php b/tests/Etc/Comment.php index 691e82e0..bdc95ffe 100644 --- a/tests/Etc/Comment.php +++ b/tests/Etc/Comment.php @@ -5,10 +5,15 @@ namespace Stancl\Tenancy\Tests\Etc; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +/** + * This model is not intended to be used with the single-database tenancy approach. + */ class Comment extends Model { protected $guarded = []; + protected $table = 'comments'; + public $timestamps = false; public function post(): BelongsTo diff --git a/tests/Etc/Post.php b/tests/Etc/Post.php index d73ed731..365e216d 100644 --- a/tests/Etc/Post.php +++ b/tests/Etc/Post.php @@ -24,6 +24,7 @@ class Post extends Model public function scoped_comments(): HasMany { - return $this->hasMany(Comment::class); + // ScopedComment = Comment model with the BelongsToPrimaryModel trait + return $this->hasMany(ScopedComment::class); } } diff --git a/tests/Etc/ScopedComment.php b/tests/Etc/ScopedComment.php index 90b4f4dd..6eca2d2a 100644 --- a/tests/Etc/ScopedComment.php +++ b/tests/Etc/ScopedComment.php @@ -11,8 +11,6 @@ class ScopedComment extends Comment { use BelongsToPrimaryModel; - protected $table = 'comments'; - public function getRelationshipToPrimaryModel(): string { return 'post';