<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\GenDoc;

class GenDocController extends Controller
{
    //
    public function fileForm(Request $request){
        $entity_id=$request->input('entity_id');
        $entity=$request->input('entity');

        if(!$request->input('entity_id'))
        {
           $entity_id=0;
        }
        $documenti = GenDoc::listDocument($entity,$entity_id);   
        return view('conti.documenti.gendoc', [
            'id'=>$entity_id,
            'entity'=>$entity,
            'documenti'=>$documenti,
        ]);
    }

    public function storeFile(Request $request){
        GenDoc::saveDocument($request);
        return redirect()->back();
    }

    public function deleteFile(Request $request)
    {
        GenDoc::delDocument($request->id);
        return redirect()->back();
    }

   
}
