From 41e224f6961f9bfedff2388dc696b46247d866be Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 15 Nov 2024 15:19:10 +0800 Subject: [PATCH] wip Signed-off-by: Mior Muhammad Zaki --- workbench/app/Models/Comment.php | 5 +++++ workbench/app/Models/Role.php | 6 +++--- workbench/app/Models/User.php | 11 +++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/workbench/app/Models/Comment.php b/workbench/app/Models/Comment.php index 584283e..74c74be 100644 --- a/workbench/app/Models/Comment.php +++ b/workbench/app/Models/Comment.php @@ -7,8 +7,11 @@ class Comment extends Model { + /** {@inheritDoc} */ protected $table = 'comments'; + /** {@inheritDoc} */ + #[\Override] public static function boot() { parent::boot(); @@ -16,6 +19,8 @@ public static function boot() static::booted(); } + /** {@inheritDoc} */ + #[\Override] public static function booted() { static::addGlobalScope('id', function (Builder $builder) { diff --git a/workbench/app/Models/Role.php b/workbench/app/Models/Role.php index 8b354d9..9a4ebc9 100644 --- a/workbench/app/Models/Role.php +++ b/workbench/app/Models/Role.php @@ -3,17 +3,17 @@ namespace Workbench\App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Role extends Model { + /** {@inheritDoc} */ protected $table = 'roles'; /** * Has many and belongs to relationship with Role. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ - public function users() + public function users(): BelongsToMany { return $this->belongsToMany(User::class, 'user_role', 'role_id', 'user_id')->withTimestamps(); } diff --git a/workbench/app/Models/User.php b/workbench/app/Models/User.php index f3801d1..66ee6bb 100644 --- a/workbench/app/Models/User.php +++ b/workbench/app/Models/User.php @@ -3,30 +3,29 @@ namespace Workbench\App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; class User extends Model { use SoftDeletes; + /** {@inheritDoc} */ protected $table = 'users'; /** * Has many to relationship with Post. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany */ - public function posts() + public function posts(): HasMany { return $this->hasMany(Post::class); } /** * Has many and belongs to relationship with Role. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ - public function roles() + public function roles(): BelongsToMany { return $this->belongsToMany(Role::class, 'user_role', 'user_id', 'role_id')->withTimestamps(); }