coolify/app/Models/TeamInvitation.php

36 lines
642 B
PHP
Raw Normal View History

2023-06-09 15:55:21 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class TeamInvitation extends Model
{
protected $fillable = [
'team_id',
2023-06-12 12:00:01 +02:00
'uuid',
2023-06-09 15:55:21 +02:00
'email',
'role',
'link',
2023-06-12 12:00:01 +02:00
'via',
2023-06-09 15:55:21 +02:00
];
2023-06-09 15:55:21 +02:00
public function team()
{
return $this->belongsTo(Team::class);
}
2024-06-10 22:43:34 +02:00
public function isValid()
{
2023-09-15 11:19:36 +02:00
$createdAt = $this->created_at;
$diff = $createdAt->diffInMinutes(now());
if ($diff <= config('constants.invitation.link.expiration')) {
return true;
} else {
$this->delete();
2024-06-10 22:43:34 +02:00
2024-03-05 09:19:15 +01:00
return false;
2023-09-15 11:19:36 +02:00
}
}
2023-06-09 15:55:21 +02:00
}