public static function generateToken($user) { $token = new Token(); $token->auth_token = bin2hex(openssl_random_pseudo_bytes(16)); $token->expires_at = (new DateTime())->add(new DateInterval('PT10M')); $token->user()->associate($user); $token->save(); return $token->auth_token; }