Make an editable jquery table using laravel

0

another question with laravel.

How could I make the table editable using jquery? I'll do it to dry, but as laravel makes it different, I'd like to know how.

This is what I have so far:

home.blade (The view)

<form method="get" action="{{url('home/seeData')}}">
<table id="table">
    <thead>
    <tr>
        <th class="text-center">Nombre</th>
        <th class="text-center">Precio ($)</th>
        <th class="text-center">Empresa</th>
        <th class="text-center">Fecha</th>
        <th class="text-center">Acciones</th>
    </tr>
    </thead>

    <tbody>
    @foreach($productos as $value)
    <tr>
    <td><center>{{ $value->nombre }}</center></td>
    <td><center>{{ $value->precio }}</center></td>
    <td><center>{{ $value->empresa }}</center></td>
    <td><center>{{ $value->updated_at }}</center></td>
    <td>
      <left><button class="edit-modal btn btn-info"
        data-info="{{$value->nombre}},{{$value->precio}},{{$value->empresa}}">
        <span class="glyphicon glyphicon-edit"></span> Editar
    </button></left>
    <left><button class="delete-modal btn btn-danger"
        data-info="{{$value->nombre}},{{$value->precio}},{{$value->empresa}}">
        <span class="glyphicon glyphicon-trash"></span> Borrar
    </button></left>
        </td>
    </tr>
    @endforeach
    </tbody>

  </table>
  </form>

What I have in HomeController (A controller)

public function seeData(){
    $products = DB::table('products')->select('id','name','email', 'updated_at')->get();
    return view('home')->with('products', $products);
}

What I have in web.php

Route::get('/home', function () {
$productos = DB::table('products')->select('nombre','precio', 'empresa', 'updated_at')->get();
return view('home', compact('productos'));
});

How can I readjust my code? I can already make them visible, I just want them to be editable and erasable. The references to jquery are already there.

    
asked by Shredder 22.10.2018 в 23:22
source

0 answers