Skip to content

Instantly share code, notes, and snippets.

@zach2825
Forked from riccardopirani/Articolo.php
Last active August 26, 2019 15:56
Show Gist options
  • Save zach2825/afe41c5a3a0dcaaebf9bb1a42b3c91a0 to your computer and use it in GitHub Desktop.
Save zach2825/afe41c5a3a0dcaaebf9bb1a42b3c91a0 to your computer and use it in GitHub Desktop.
Display select values with Laravel
public function GetArticoli($IdUtente)
{
// if you have a Articolo model.
$articoli = App\Articolo::where('IdUtente', '=', $IdUtente)->get();
return view('gestionearticoli', compact('articoli'));
}
<table id="mytable" class="table table-bordred table-striped">
<thead>
<th>IdArticolo</th>
<th>Codice Articolo</th>
<th>Prezzo</th>
<th>Modifica</th>
<th>Elimina</th>
</thead>
<tbody>
@forelse ($articoli as $art)
<tr>
<td>{{$art->IdArticolo}}</td>
<td>{{$art->CodiceArticolo}}</td>
<td>{{$art->Prezzo}}</td>
<td>
<p data-placement='top' data-toggle='tooltip' title='Edit'>
<button class='btn btn-primary btn-xs' data-title='Edit' data-toggle='modal' data-target='#edit'><span class='glyphicon glyphicon-pencil'></span></button>
</p>
</td>
<td>
<p data-placement='top' data-toggle='tooltip' title='Delete'>
<button class='btn btn-danger btn-xs' data-title='Delete' data-toggle='modal' data-target='#delete'><span class='glyphicon glyphicon-trash'></span></button>
</p>
</td>
</tr>
@empty
<tr>
<td colspan="50">No Results</td>
</tr>
@endforelse
</tbody>
</table>
Route::get('/recuperoarticoliutente/{IdUtente}', 'Articolo@GetArticoli');
@zach2825
Copy link
Author

Note, I set colspan of the output empty row to something really high it just expands to take up how many tags there are..

@riccardopirani
Copy link

i have update original code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment