Commit iniziale
This commit is contained in:
106
app/Http/Controllers/ContoController.php
Normal file
106
app/Http/Controllers/ContoController.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Conto;
|
||||
use Illuminate\Http\Request;
|
||||
//use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
|
||||
class ContoController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$conti=Conto::all();
|
||||
return view('conti.conto.index',compact('conti'));
|
||||
}
|
||||
|
||||
public function apiListConto()
|
||||
{
|
||||
//
|
||||
$conti=Conto::all();
|
||||
return json_encode($conti);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
return view('conti.conto.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$conto=Conto::create($request->all());
|
||||
return redirect()->to('/admin/conti');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Conto $conti)
|
||||
{
|
||||
//
|
||||
$conto=Conto::find($conti);
|
||||
return view('conti.conto.show',compact('conto'));
|
||||
/*
|
||||
Rivedere il passaggio parametri e indicare anche le variabili $conto->saldo_anno_corrente $conto->saldo_anno_precedente $conto->saldo_anno_precedente_2
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Conto $conti)
|
||||
{
|
||||
//
|
||||
$conto=Conto::find($conti);
|
||||
return json_encode($conto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Conto $conti)
|
||||
{
|
||||
$validated= $request->validate([
|
||||
'nomeConto'=>'required',
|
||||
'Banca'=>'required',
|
||||
//'IBAN'=>'required',
|
||||
//'saldo_iniziale'=>'required',
|
||||
//'note'=>'required',
|
||||
]);
|
||||
//
|
||||
/*$conto = Conto::find($conti);
|
||||
$conto->nomeConto=$request->nomeConto;
|
||||
$conto->Banca=$request->Banca;
|
||||
$conto->IBAN=$request->IBAN;
|
||||
$conto->saldo_iniziale=$request->saldo_iniziale;
|
||||
$conto->note=$request->note;
|
||||
$conto->save();*/
|
||||
Conto::whereId($conti->id)->update($request->except('_token','_method'));
|
||||
return redirect()->to('/admin/conti');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Conto $conto)
|
||||
{
|
||||
//
|
||||
$conti=Conto::find($conto);
|
||||
$conti->delete();
|
||||
return redirect()->route('conti.conto.index');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user