Creato Controller e model Cliente
This commit is contained in:
parent
e9b1eb8d09
commit
95495035a3
38
app/Http/Controllers/ClienteController.php
Normal file
38
app/Http/Controllers/ClienteController.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Cliente;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ClienteController extends Controller
|
||||||
|
{
|
||||||
|
// Classe di gestione del cliente
|
||||||
|
public function listCliente(){
|
||||||
|
return view('cliente.list',['clienti'=>Cliente::all()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newCliente(){
|
||||||
|
return view('cliente.new');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveCliente(Request $parm)
|
||||||
|
{
|
||||||
|
Cliente::saveNewCliente($parm);
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editCliente($id){
|
||||||
|
return view('cliente.edit',['cliente'=>$id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateCliente(Request $parm){
|
||||||
|
Cliente::updateCliente($parm);
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteCliente($id){
|
||||||
|
Cliente::deleteCliente($id);
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
}
|
@ -30,18 +30,18 @@ class HomeController extends Controller
|
|||||||
public function roles()
|
public function roles()
|
||||||
{
|
{
|
||||||
// ritornare view con lista ruoli
|
// ritornare view con lista ruoli
|
||||||
dd(User::getAllRoles());
|
return view('administration.roles.list', ['ruoli'=>User::getAllRoles()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function permissions()
|
public function permissions()
|
||||||
{
|
{
|
||||||
// ritornare view con lista permessi
|
// ritornare view con lista permessi
|
||||||
dd(User::getAllPermissions());
|
return view('administration.permissions.list', ['permessi'=>User::getAllPermissions()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function users()
|
public function users()
|
||||||
{
|
{
|
||||||
// ritornare view con lista utenti
|
// ritornare view con lista utenti
|
||||||
dd(User::all());
|
return view('administration.users.list', ['utenti'=>User::all()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
81
app/Models/Cliente.php
Normal file
81
app/Models/Cliente.php
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Cliente extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable=[
|
||||||
|
'Nome',
|
||||||
|
'Cognome',
|
||||||
|
'Azienda',
|
||||||
|
'CodiceFiscale',
|
||||||
|
'PartitaIva',
|
||||||
|
'Indirizzo',
|
||||||
|
'Cap',
|
||||||
|
'Citta',
|
||||||
|
'Provincia',
|
||||||
|
'Nazione',
|
||||||
|
'Telefono',
|
||||||
|
'Cellulare',
|
||||||
|
'Email',
|
||||||
|
'Note',
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function getClienteById($id)
|
||||||
|
{
|
||||||
|
return self::find($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function saveNewCliente($parm)
|
||||||
|
{
|
||||||
|
self::create([
|
||||||
|
'Nome'=>$parm['nome'],
|
||||||
|
'Cognome'=>$parm['cognome'],
|
||||||
|
'Azienda'=>$parm['azienda'],
|
||||||
|
'CodiceFiscale'=>$parm['codfis'],
|
||||||
|
'PartitaIva'=>$parm['piva'],
|
||||||
|
'Indirizzo'=>$parm['indirizzo'],
|
||||||
|
'Cap'=>$parm['cap'],
|
||||||
|
'Citta'=>$parm['citta'],
|
||||||
|
'Provincia'=>$parm['prov'],
|
||||||
|
'Nazione'=>$parm['nazione'],
|
||||||
|
'Telefono'=>$parm['tel'],
|
||||||
|
'Cellulare'=>$parm['cellulare'],
|
||||||
|
'Email'=>$parm['email'],
|
||||||
|
'Note'=>$parm['note'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function updateCliente($parm){
|
||||||
|
$id = $parm['id'];
|
||||||
|
$cliente = self::find($id);
|
||||||
|
$cliente->Nome = $parm['nome'];
|
||||||
|
$cliente->Cognome = $parm['cognome'];
|
||||||
|
$cliente->Azienda = $parm['azienda'];
|
||||||
|
$cliente->CodiceFiscale = $parm['codfis'];
|
||||||
|
$cliente->PartitaIva = $parm['piva'];
|
||||||
|
$cliente->Indirizzo = $parm['indirizzo'];
|
||||||
|
$cliente->Cap = $parm['cap'];
|
||||||
|
$cliente->Citta = $parm['citta'];
|
||||||
|
$cliente->Provincia = $parm['prov'];
|
||||||
|
$cliente->Nazione = $parm['nazione'];
|
||||||
|
$cliente->Telefono = $parm['tel'];
|
||||||
|
$cliente->Cellulare = $parm['cellulare'];
|
||||||
|
$cliente->Email = $parm['email'];
|
||||||
|
$cliente->Note = $parm['note'];
|
||||||
|
$cliente->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function deleteCliente($id)
|
||||||
|
{
|
||||||
|
$cliente = self::find($id);
|
||||||
|
$cliente->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('clientes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('clientes');
|
||||||
|
}
|
||||||
|
};
|
31
resources/views/administration/permissions/list.blade.php
Normal file
31
resources/views/administration/permissions/list.blade.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">{{ __('Permessi') }}</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<table class="table table-responsive">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<th> Permesso </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($permessi as $permesso)
|
||||||
|
<tr>
|
||||||
|
<td>{{$permesso->id}}</td>
|
||||||
|
<td>{{$permesso->name}}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
31
resources/views/administration/roles/list.blade.php
Normal file
31
resources/views/administration/roles/list.blade.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">{{ __('Ruoli') }}</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<table class="table table-responsive">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> Id </th>
|
||||||
|
<th> Ruolo </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($ruoli as $ruolo)
|
||||||
|
<tr>
|
||||||
|
<td>{{$ruolo->id}}</td>
|
||||||
|
<td>{{$ruolo->name}}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
33
resources/views/administration/users/list.blade.php
Normal file
33
resources/views/administration/users/list.blade.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">{{ __('Utenti') }}</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<table class="table table-responsive">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> Id </th>
|
||||||
|
<th> Nome </th>
|
||||||
|
<th> Email </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($utenti as $utente)
|
||||||
|
<tr>
|
||||||
|
<td>{{$utente->id}}</td>
|
||||||
|
<td>{{$utente->name}}</td>
|
||||||
|
<td>{{$utente->email}}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
Loading…
Reference in New Issue
Block a user