From dc81b0ec201168706c842d21b11ad2db1b4b3215 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Thu, 27 Apr 2023 18:01:37 +0200 Subject: [PATCH] Move classes to separate files --- tests/Etc/Comment.php | 17 ++++++++++ tests/Etc/Post.php | 25 ++++++++++++++ tests/Etc/ScopedComment.php | 17 ++++++++++ tests/SingleDatabaseTenancyTest.php | 52 +++-------------------------- 4 files changed, 64 insertions(+), 47 deletions(-) create mode 100644 tests/Etc/Comment.php create mode 100644 tests/Etc/Post.php create mode 100644 tests/Etc/ScopedComment.php diff --git a/tests/Etc/Comment.php b/tests/Etc/Comment.php new file mode 100644 index 00000000..27284e2f --- /dev/null +++ b/tests/Etc/Comment.php @@ -0,0 +1,17 @@ +belongsTo(Post::class); + } +} diff --git a/tests/Etc/Post.php b/tests/Etc/Post.php new file mode 100644 index 00000000..94c70fbf --- /dev/null +++ b/tests/Etc/Post.php @@ -0,0 +1,25 @@ +hasMany(Comment::class); + } + + public function scoped_comments() + { + return $this->hasMany(Comment::class); + } +} diff --git a/tests/Etc/ScopedComment.php b/tests/Etc/ScopedComment.php new file mode 100644 index 00000000..733d1ea9 --- /dev/null +++ b/tests/Etc/ScopedComment.php @@ -0,0 +1,17 @@ +hasMany(Comment::class); - } - - public function scoped_comments() - { - return $this->hasMany(Comment::class); - } -} - -class Comment extends Model -{ - protected $guarded = []; - - public $timestamps = false; - - public function post() - { - return $this->belongsTo(Post::class); - } -} - -class ScopedComment extends Comment -{ - use BelongsToPrimaryModel; - - protected $table = 'comments'; - - public function getRelationshipToPrimaryModel(): string - { - return 'post'; - } -} - class GlobalResource extends Model { protected $guarded = [];