lasthourcloud/app/Models/TeamInvitation.php
2024-06-10 20:43:34 +00:00

36 lines
642 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class TeamInvitation extends Model
{
protected $fillable = [
'team_id',
'uuid',
'email',
'role',
'link',
'via',
];
public function team()
{
return $this->belongsTo(Team::class);
}
public function isValid()
{
$createdAt = $this->created_at;
$diff = $createdAt->diffInMinutes(now());
if ($diff <= config('constants.invitation.link.expiration')) {
return true;
} else {
$this->delete();
return false;
}
}
}