add developper binding to platform

This commit is contained in:
2026-03-05 10:22:54 +08:00
parent 4c49c2b71c
commit 1d7a4c7176
3 changed files with 56 additions and 3 deletions
+15
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\DbConnection\Model\Model;
use Qbhy\HyperfAuth\Authenticatable;
@@ -91,6 +92,20 @@ class User extends Model implements Authenticatable
return password_verify($password, $this->password);
}
public function developedPlatforms(): HasMany
{
return $this->hasMany(Platform::class, 'developer_id');
}
protected static function boot(): void
{
parent::boot();
static::deleting(function (User $user) {
$user->developedPlatforms()->update(['developer_id' => 1]);
});
}
/**
* Check if refresh token is valid.
*/