Request returning Decimal

Asked

Viewed 52 times

0

Guys I have a field in a form that is type text and when I give a post in the form and capituro the request->get this field returns string when it has some letter in it. but if it only contains numbers it returns in reqeust->get as decimal.

How do I make it always return string even when it is only number?

 {!! Form::text('background', NULL, ['class'=>'form-control', 'maxlength'=>'6', 'id' => 'background']) !!}

If I fill with for example 007788 the dd($request->get('background')); returns as 7788.00 ai if I put a07788 the dd($request->get('background')); returns a07788

Thank you

  • Folks look over this my question is something in the Laravel 5.1 Request Library. I did a test by placing dd($_POST['background']) and to my surprise the answer was a string with 007788. Then the Request class is turning into number at once keep the string. Does anyone know how to take this?

1 answer

0

Cast the type you want:

  • String

    dd((string) $request->get('background'))

  • Integer

    dd((int) $request->get('background'));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.