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

Add docblocks to single-db models, add return types to relationship methods

This commit is contained in:
lukinovec 2023-05-22 15:01:49 +02:00
parent c13fe5183f
commit a46b26800f
3 changed files with 11 additions and 3 deletions

View file

@ -3,6 +3,7 @@
namespace Stancl\Tenancy\Tests\Etc; namespace Stancl\Tenancy\Tests\Etc;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Comment extends Model class Comment extends Model
{ {
@ -10,7 +11,7 @@ class Comment extends Model
public $timestamps = false; public $timestamps = false;
public function post() public function post(): BelongsTo
{ {
return $this->belongsTo(Post::class); return $this->belongsTo(Post::class);
} }

View file

@ -3,8 +3,12 @@
namespace Stancl\Tenancy\Tests\Etc; namespace Stancl\Tenancy\Tests\Etc;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Stancl\Tenancy\Database\Concerns\BelongsToTenant; use Stancl\Tenancy\Database\Concerns\BelongsToTenant;
/**
* This model is intended to be used with the single-database tenancy approach.
*/
class Post extends Model class Post extends Model
{ {
use BelongsToTenant; use BelongsToTenant;
@ -13,12 +17,12 @@ class Post extends Model
public $timestamps = false; public $timestamps = false;
public function comments() public function comments(): HasMany
{ {
return $this->hasMany(Comment::class); return $this->hasMany(Comment::class);
} }
public function scoped_comments() public function scoped_comments(): HasMany
{ {
return $this->hasMany(Comment::class); return $this->hasMany(Comment::class);
} }

View file

@ -4,6 +4,9 @@ namespace Stancl\Tenancy\Tests\Etc;
use Stancl\Tenancy\Database\Concerns\BelongsToPrimaryModel; use Stancl\Tenancy\Database\Concerns\BelongsToPrimaryModel;
/**
* This model is intended to be used with the single-database tenancy approach.
*/
class ScopedComment extends Comment class ScopedComment extends Comment
{ {
use BelongsToPrimaryModel; use BelongsToPrimaryModel;