datatable.directory codebase https://datatable.directory/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
datatable.directory/app/Models/EmailConfirmation.php

42 lines
952 B

<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
/**
* E-mail confirmation
*
* @property int $id
* @property \Carbon\Carbon $created_at
* @property int $user_id
* @property string $token
6 years ago
* @property string $email
* @property-read User $user
* @method $this|Builder valid()
*/
class EmailConfirmation extends BaseModel
{
protected $guarded = [];
const UPDATED_AT = null; // disable update timestamp
const EXPIRATION_H = 2; // 2h
/** Authoring user */
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function scopeValid(Builder $query)
{
return $query->where('created_at', '>=',
Carbon::now()->subHours(self::EXPIRATION_H));
}
public function scopeExpired(Builder $query)
{
return $query->where('created_at', '<',
Carbon::now()->subHours(self::EXPIRATION_H));
}
}