2021-05-04 14:21:18 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
class Invite extends NexusModel
|
|
|
|
|
{
|
|
|
|
|
protected $table = 'invites';
|
|
|
|
|
|
2021-05-10 20:05:52 +08:00
|
|
|
const VALID_YES = 1;
|
|
|
|
|
const VALID_NO = 0;
|
|
|
|
|
|
2022-12-13 13:51:39 +08:00
|
|
|
protected $casts = [
|
|
|
|
|
'expired_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
|
2021-05-10 20:05:52 +08:00
|
|
|
public static $validInfo = [
|
|
|
|
|
self::VALID_NO => ['text' => 'No'],
|
|
|
|
|
self::VALID_YES => ['text' => 'Yes'],
|
|
|
|
|
];
|
|
|
|
|
|
2021-05-04 14:21:18 +08:00
|
|
|
protected $fillable = [
|
2021-05-11 01:41:58 +08:00
|
|
|
'inviter', 'invitee', 'hash', 'time_invited', 'valid',
|
|
|
|
|
'invitee_register_uid', 'invitee_register_email', 'invitee_register_username'
|
2021-05-04 14:21:18 +08:00
|
|
|
];
|
2021-05-10 20:05:52 +08:00
|
|
|
|
|
|
|
|
public function getValidTextAttribute()
|
|
|
|
|
{
|
|
|
|
|
return self::$validInfo[$this->valid]['text'] ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-14 20:41:43 +08:00
|
|
|
public function inviter_user()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class, 'inviter');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function invitee_user()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class, 'invitee_register_uid');
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-04 14:21:18 +08:00
|
|
|
}
|