. */ namespace App\Rules; use App\AccountCreationToken as AppAccountCreationToken; use Illuminate\Contracts\Validation\Rule; class AccountCreationTokenNotExpired implements Rule { public function passes($attribute, $value) { $token = AppAccountCreationToken::where('token', $value)->where('used', false)->first(); return $token && !$token->expired(); } public function message() { return 'The provided token is expired'; } }