Last active
August 26, 2019 15:59
-
-
Save riccardopirani/71825e7c4618f7b9559b88922ab15904 to your computer and use it in GitHub Desktop.
Display select values with Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this is model | |
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Articolo extends Model | |
{ | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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')); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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