阶段更新

This commit is contained in:
2023-01-12 14:47:38 +08:00
parent 088dd64b2f
commit 5b8901281c
626 changed files with 39326 additions and 12 deletions

View File

@@ -0,0 +1,53 @@
<?php
namespace Modules\User\Models;
use App\Models\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Modules\User\Traits\BelongsToUser;
class UserInvite extends Model
{
use BelongsToUser;
const STATUS_INIT = 1;
const STATUS_ALLOT = 2;
const STATUS_USED = 3;
const STATUS = [
self::STATUS_INIT => '未分配',
self::STATUS_ALLOT => '已分配',
self::STATUS_USED => '已激活',
];
protected $dates = [
'actived_at',
];
public function activeUser(): BelongsTo
{
return $this->belongsTo(User::class, 'active_id');
}
public function getStatusTextAttribute()
{
return self::STATUS[$this->status] ?? '未知';
}
/**
* Notes: 激活
*
* @Author: 玄尘
* @Date: 2022/9/21 10:11
* @param $user_id
*/
public function use($user_id)
{
$this->update([
'active_id' => $user_id,
'actived_at' => now(),
'status' => self::STATUS_USED,
]);
}
}