mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
45 lines
977 B
PHP
45 lines
977 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
class Invite extends NexusModel
|
|
{
|
|
protected $table = 'invites';
|
|
|
|
const VALID_YES = 1;
|
|
const VALID_NO = 0;
|
|
|
|
const TEMPORARY_INVITE_VALID_DAYS = 7;
|
|
|
|
protected $casts = [
|
|
'expired_at' => 'datetime',
|
|
];
|
|
|
|
public static $validInfo = [
|
|
self::VALID_NO => ['text' => 'No'],
|
|
self::VALID_YES => ['text' => 'Yes'],
|
|
];
|
|
|
|
protected $fillable = [
|
|
'inviter', 'invitee', 'hash', 'time_invited', 'valid',
|
|
'invitee_register_uid', 'invitee_register_email', 'invitee_register_username',
|
|
'pre_register_email', 'pre_register_username',
|
|
];
|
|
|
|
public function getValidTextAttribute()
|
|
{
|
|
return self::$validInfo[$this->valid]['text'] ?? '';
|
|
}
|
|
|
|
public function inviter_user()
|
|
{
|
|
return $this->belongsTo(User::class, 'inviter');
|
|
}
|
|
|
|
public function invitee_user()
|
|
{
|
|
return $this->belongsTo(User::class, 'invitee_register_uid');
|
|
}
|
|
|
|
}
|