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