1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 15:54:03 +00:00

Make the (Scoped)Comment model distinction clearer

This commit is contained in:
lukinovec 2023-05-24 15:12:35 +02:00
parent 47fe86c21e
commit 1f9a344f33
3 changed files with 7 additions and 3 deletions

View file

@ -5,10 +5,15 @@ namespace Stancl\Tenancy\Tests\Etc;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* This model is not intended to be used with the single-database tenancy approach.
*/
class Comment extends Model class Comment extends Model
{ {
protected $guarded = []; protected $guarded = [];
protected $table = 'comments';
public $timestamps = false; public $timestamps = false;
public function post(): BelongsTo public function post(): BelongsTo

View file

@ -24,6 +24,7 @@ class Post extends Model
public function scoped_comments(): HasMany public function scoped_comments(): HasMany
{ {
return $this->hasMany(Comment::class); // ScopedComment = Comment model with the BelongsToPrimaryModel trait
return $this->hasMany(ScopedComment::class);
} }
} }

View file

@ -11,8 +11,6 @@ class ScopedComment extends Comment
{ {
use BelongsToPrimaryModel; use BelongsToPrimaryModel;
protected $table = 'comments';
public function getRelationshipToPrimaryModel(): string public function getRelationshipToPrimaryModel(): string
{ {
return 'post'; return 'post';