Duda numeric format in laravel 5.5

1

what difference there is between such a variable.

$numero = 1;

and a number that comes from this way.

$valorusuario = $request->numero;

Is there a way that the number that comes from $valorusuario can convert it to the format that has the variable $numero ?

I turned it into int, but I'm still the same

     /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function selectord(Request $request)
    {

        $valorusuario = $request->valorusuario;
        $int = (intval(var))$valorusuario;

        $numero = 1;
       
     
        $consultarea=usuarios::where('user_id', $numero)->paginate(2);
        $usuariosOpciones=usuarios::pluck('usuario_ad', 'user_id')->unique();
        return view('usuario.consultareas',compact('consultarea','usuariosOpciones'));
      
    }

If for example I use a simple variable like $ number, the paging works perfect, but if I use the variable $ int that I converted, it loads the first page but not the following, I do not understand what the difference may be so that it is or happen.

    
asked by zereft 13.11.2018 в 02:15
source

1 answer

0

Due to the 4 posts that you have already created dealing with the same topic (please only update one, do not create several), I can deduce that what happens is that when you go to page 2, the value of $request->valorusuario it returns null. So your query will not return data when it becomes:

  

Users :: where ('user_id', null ) - > paginate (2);

To solve your problem, add your paginate: ->appends(['valorusuario' => $valorusuario]);

It would stay like this:

$valorusuario = $request->valorusuario;
$consultarea=usuarios::where('user_id', $numero)->paginate(2)->appends(['valorusuario' => $valorusuario]);
    
answered by 13.11.2018 в 03:42