Skip to content

Instantly share code, notes, and snippets.

@riccardopirani
Last active August 26, 2019 15:59
Show Gist options
  • Save riccardopirani/71825e7c4618f7b9559b88922ab15904 to your computer and use it in GitHub Desktop.
Save riccardopirani/71825e7c4618f7b9559b88922ab15904 to your computer and use it in GitHub Desktop.
Display select values with Laravel
//this is model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Articolo extends Model
{
}
?>
<?php
namespace App\Http\Controllers;
use DB;
use App\Quotation;
use Illuminate\Http\Request;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Mockery\Exception;
use App\Console\Commands\Emails;
use Session;
class Articolo extends Controller
{
//Parametri per l'inserimento dell'articolo nel database
protected $user, $codicearticolo, $prezzo;
//Questa funzione permettere di recuperare gli articoli inseriti da un utente
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>
<?php
Route::get('/recuperoarticoliutente/{IdUtente}', 'Articolo@GetArticoli');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment