44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class GenDoc extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
// DocumentiGenerali
|
|
|
|
public static function saveDocument($data){
|
|
|
|
$filename=$data->file('filename')->store('Documenti');
|
|
DB::table('gen_docs')
|
|
->insert([
|
|
'entity'=>$data['entity'],
|
|
'entity_id'=>$data['entity_id'],
|
|
'descrizione'=>$data['descrizione'],
|
|
'filename'=>$filename,
|
|
]);
|
|
}
|
|
|
|
public static function listDocument($entity,$entity_id)
|
|
{
|
|
// Ritorna la lista dei documenti in base all'entità e al rispettivo id
|
|
return DB::table('gen_docs')->where('entity','=',$entity)->andWere('entity_id','=',$entity_id)->get();
|
|
}
|
|
|
|
public static function countDocument($entity,$entity_id){
|
|
// Conta i documenti inseriti per la determinata entità e id
|
|
$quanti=DB::table('gen_docs')
|
|
->where('entity','=',$entity)
|
|
->andWhere('entity_id','=',$entity_id)
|
|
->count();
|
|
return $quanti;
|
|
}
|
|
|
|
|
|
}
|