96 lines
2.4 KiB
PHP
96 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\CotrattiAffitti;
|
|
use Illuminate\Http\Request;
|
|
use Barryvdh\DomPDF\Facade\Pdf;
|
|
|
|
class CotrattiAffittiController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
//
|
|
return view('affitti.contratti.index',[
|
|
'contratti' => CotrattiAffitti::all()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
return view('affitti.contratti.create',[
|
|
'immobili' => \App\Models\Immobili::all()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
$data = $request->validate([
|
|
'immobile_id' => 'required|exists:immobilis,id',
|
|
'tipo_contratto_id' => 'required|exists:tipo_contrattos,id',
|
|
'data_inizio' => 'nullable|date',
|
|
'data_fine' => 'nullable|date',
|
|
'tacito_rinnovo' => 'nullable|boolean',
|
|
'canone_mensile' => 'nullable|string|max:255',
|
|
'deposito_cauzionale' => 'nullable|string|max:255',
|
|
'spese_condominiali' => 'nullable|string|max:255',
|
|
'iva' => 'nullable|string|max:255',
|
|
'registrazione' => 'nullable|string|max:255',
|
|
'note' => 'nullable|string|max:1000',
|
|
]);
|
|
CotrattiAffitti::create($data);
|
|
return redirect()->route('contratti_affitti');
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(CotrattiAffitti $cotrattiAffitti)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(CotrattiAffitti $cotrattiAffitti)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, CotrattiAffitti $cotrattiAffitti)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(CotrattiAffitti $cotrattiAffitti)
|
|
{
|
|
//
|
|
}
|
|
|
|
public function renderPdf(CotrattiAffitti $cotrattiAffitti)
|
|
{
|
|
//
|
|
$contratto=CotrattiAffitti::find($cotrattiAffitti->id);
|
|
$pdf = PDF::loadView('affitti.contratti.pdf', compact('contratto'));
|
|
return $pdf->download('contratto.pdf');
|
|
}
|
|
}
|