diff --git a/app/Http/Controllers/GenDocController.php b/app/Http/Controllers/GenDocController.php new file mode 100644 index 0000000..89d633c --- /dev/null +++ b/app/Http/Controllers/GenDocController.php @@ -0,0 +1,10 @@ +file('filename')->store('Documenti'); + DB::table('gen_docs') + ->insert([ + 'entity'=>$entity, + 'entity_id'=>$data->input('id'), + 'descrizione'=>$data->input('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; + } + + +} diff --git a/database/migrations/2023_09_12_083340_create_gen_docs_table.php b/database/migrations/2023_09_12_083340_create_gen_docs_table.php new file mode 100644 index 0000000..5fea84f --- /dev/null +++ b/database/migrations/2023_09_12_083340_create_gen_docs_table.php @@ -0,0 +1,36 @@ +id(); + $table->timestamps(); + $table->integer('entity')->unsigned(); + $table->bigInteger('entity_id'); + $table->string('filename', 255); + $table->longText('descrizone'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('gen_docs'); + } +}