The interrogation of the postgresql digest function in the procedure works on pgadmin but does not work by calling via Laravel

Recently, I created a stored procedure in Postgres Sql that deals with hashing passwords. When it is used via the PgAdmin tool, it works like a charm, as shown below.

I've also installed the pgcrypto extension.

SELECT horeca_user.update_token (
1, // user_id
1, // type
Token // sdsfsdfs & # 39;
)

It works when it is called via the pgadmin tool, but not in the laravel application as shown below.

$ token =  DB :: select ("SELECT * from " horeca_user  ". update_token (& # 39; $ type & # 39; $ user_id & # 39; $ token & # 39; ) ");

and finally it's my code of procedure

CREATE OR REPLACE FUNCTION horeca_user.update_token (integer tp, integer user-id, variant token character)
RETURNS character variant
LANGUAGE & # 39; plpgsql & # 39; VOLATILE
PARALLEL UNSAFE
COST 100
AS $ BODY $
DECLARE uid INTEGER;
DECLARE the variable tok character;
TO START
uid: = 0;
Select count (*) as the total of horeca_user.user_tokens where user_id = 2 $ in uid;

if uid = 0 THEN
Insert into horeca_user.user_tokens (id, user_id, tip), values ​​($ 3, $ 2, $ 1);
other
Update horeca_user.user_tokens set id = $ 3, tip = $ 1 where user_id = $ 2;
END IF;

SELECT encode (digest (token, 'sha256'), 'hex' as tt in tok;

back tok;
END

$ BODY $;