Control messages in laravel 5.5 forms

2

I have a form which gives me a query of a certain number of records, I would like it when these records appear to show a message on the top that says how many records I consult, but I have no idea how to handle these messages in laravel Does anyone know any techniques?

I tried to do it like that ..

 * @return \Illuminate\Http\Response
     */
    public function listusuario()
    {

        $user=user::orderBy('id','DESC')->paginate(10);
        $conteo=User::count();
        return view('usuario.ecuenta',compact('user'));
        return redirect()->back()->withSuccess('IT WORKS!');

    }

and I intend to receive it in the view

 @if(session('success'))
      <div class="alert alert-success">
        <h1>{{session('success')}}</h1>
      </div>
      @endif
    
asked by zereft 20.11.2018 в 01:26
source

1 answer

1

I would send both variables to the view, in this way:

public function listusuario()
    {

        $user=user::orderBy('id','DESC')->paginate(10);
        $conteo=User::count();
        return view('usuario.ecuenta')->with(["user" => $user, "conteo" => $conteo]);
        return redirect()->back()->withSuccess('IT WORKS!');

    }

With the help of the with() method, you can send more than one variable to your view, only accommodate them in the form of an associative arrangement; that is, in the format of "clave" => $valor

After that, in your view it should only be like this:

Total de registros: {{ $conteo }}
    
answered by 20.11.2018 / 01:38
source