Commit workspace changes
This commit is contained in:
69
app/Models/GroupInvitation.php
Normal file
69
app/Models/GroupInvitation.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class GroupInvitation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const STATUS_PENDING = 'pending';
|
||||
public const STATUS_ACCEPTED = 'accepted';
|
||||
public const STATUS_DECLINED = 'declined';
|
||||
public const STATUS_REVOKED = 'revoked';
|
||||
public const STATUS_EXPIRED = 'expired';
|
||||
|
||||
protected $fillable = [
|
||||
'group_id',
|
||||
'invited_user_id',
|
||||
'invited_by_user_id',
|
||||
'source_group_member_id',
|
||||
'role',
|
||||
'status',
|
||||
'token',
|
||||
'note',
|
||||
'invited_at',
|
||||
'expires_at',
|
||||
'responded_at',
|
||||
'accepted_at',
|
||||
'revoked_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'invited_at' => 'datetime',
|
||||
'expires_at' => 'datetime',
|
||||
'responded_at' => 'datetime',
|
||||
'accepted_at' => 'datetime',
|
||||
'revoked_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'token';
|
||||
}
|
||||
|
||||
public function group(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Group::class);
|
||||
}
|
||||
|
||||
public function invitedUser(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'invited_user_id');
|
||||
}
|
||||
|
||||
public function invitedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'invited_by_user_id');
|
||||
}
|
||||
|
||||
public function sourceGroupMember(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(GroupMember::class, 'source_group_member_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user