Sistemazione e pulizia Model-Controller per Categorie, Contatore Enel, ContatoreGas, Documenti e inserimento form per registrazione operazioni auto in movimenti
This commit is contained in:
@@ -14,4 +14,34 @@ class Categorie extends Model
|
||||
{
|
||||
return DB::table('categories')->where('cat_name',$name)->get('id');
|
||||
}
|
||||
|
||||
public static function list()
|
||||
{
|
||||
return DB::table('categories')->orderBy('cat_name')->get();
|
||||
}
|
||||
|
||||
public static function inserisci($name){
|
||||
return DB::table('categories')->insert(['cat_name'=> $name]);
|
||||
}
|
||||
|
||||
public static function deleteById($id){
|
||||
DB::table('categories')
|
||||
->where('id','=', $id)
|
||||
->delete();
|
||||
}
|
||||
|
||||
public static function getById($id) {
|
||||
return DB::table('categories')
|
||||
->where('categories.id','=',$id)
|
||||
->get();
|
||||
}
|
||||
|
||||
public static function updateNameById($id,$name) {
|
||||
DB::table('categories')
|
||||
->where('id','=', $id)
|
||||
->update([
|
||||
'cat_name' => $name,
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Documenti extends Model
|
||||
{
|
||||
@@ -15,5 +16,23 @@ class Documenti extends Model
|
||||
->count();
|
||||
return $quanti;
|
||||
}
|
||||
|
||||
public static function store($req) {
|
||||
$movimento_id=$req->input('id');
|
||||
$filename=$req->file('filename')->store('Documenti');
|
||||
DB::table('documentis')
|
||||
->insert([
|
||||
'movimenti_id'=>$movimento_id,
|
||||
'descrizione'=>$req->input('descrizione'),
|
||||
'filename'=>$filename,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getList($id)
|
||||
{
|
||||
return DB::table('documentis')
|
||||
->where('movimenti_id','=',$id)
|
||||
->get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class Operazione extends Model
|
||||
{
|
||||
|
||||
$automobile=Auto::getAutoById($data['auto']);
|
||||
$auto=' '.$automobile['marca'].' '.$automobile['modello'].' '.$automobile['targa'];
|
||||
$auto=' '.$automobile->marca.' '.$automobile->modello.' '.$automobile->targa;
|
||||
$categoria=Categorie::getIdCategoriaByName('Automobili');
|
||||
$causale="Automobili: ".strtoUpper($data['type']).' ';
|
||||
|
||||
@@ -49,9 +49,11 @@ class Operazione extends Model
|
||||
|
||||
DB::table('movimentis')->insert([
|
||||
'mov_data'=>$data['data'],
|
||||
'mov_descrizione'=>'Automobili: '.strtoUpper($data['type']).' '.$auto,
|
||||
'mov_descrizione'=>$causale,
|
||||
'mov_importo'=>'-'.$data['importo'],
|
||||
'mov_fk_categoria'=> $categoria,
|
||||
'mov_fk_categoria'=> 1,
|
||||
'mov_inserito_da'=>1,
|
||||
'mov_fk_tags'=>1,
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,24 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class contatoreEnEl extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public static function inserisci($data) {
|
||||
DB::table('contatore_en_els')->insert([
|
||||
'enel_date'=> $data['enel_date'],
|
||||
'enel_A'=> $data['enel_A'],
|
||||
'enel_R'=> $data['enel_R'],
|
||||
'enel_F1'=> $data['enel_F1'],
|
||||
'enel_F2'=> $data['enel_F2'],
|
||||
'enel_F3'=> $data['enel_F3'],
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getList() {
|
||||
return DB::table('contatore_en_els')->orderBy('enel_date','desc')->get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,21 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class contatoreGas extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public static function getList()
|
||||
{
|
||||
return DB::table('contatore_gases')->orderBy('gas_date','asc')->get();
|
||||
}
|
||||
|
||||
public static function inserisci($data) {
|
||||
DB::table('contatore_gases')->insert([
|
||||
'gas_date'=> $data['gas_date'],
|
||||
'gas_lettura'=> $data['gas_lettura'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user