Allineamento API

This commit is contained in:
Pek5892 2024-03-13 10:14:41 +01:00
parent 0af35e0a64
commit 3adc516ed2
7 changed files with 40 additions and 58 deletions

View File

@ -38,14 +38,12 @@ class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface
];
$joins[] = [
'`an_nazioni_lang`',
'`an_anagrafiche`.`id_nazione`',
'`an_nazioni_lang`.`name`',
];
'an_nazioni_lang' => '`an_nazioni_lang`.`id_record` = `an_nazioni`.`id` AND `an_nazioni_lang`.`id_lang` = '.setting('Lingua'),
];
$where[] = ['`an_anagrafiche`.`deleted_at`', '=', null];
$order['an_anagrafiche.ragione_sociale'] = 'ASC';
$order['`an_anagrafiche`.`ragione_sociale`'] = 'ASC';
if ($request['resource'] != 'anagrafiche') {
$type = 'Cliente';

View File

@ -33,41 +33,39 @@ class Articoli extends Resource implements RetrieveInterface, UpdateInterface, C
$table = 'mg_articoli';
$select = [
'mg_articoli.*',
'categorie.nome AS categoria',
'sottocategorie.nome AS sottocategoria',
'`categorie`.`nome` AS categoria',
'`sottocategorie`.`nome` AS sottocategoria',
];
$joins[] = [
'mg_articoli_lang',
'mg_articoli.id',
'mg_articoli_lang.id_record',
];
$joins[] = [
'mg_categorie AS categorie',
'mg_articoli.id_categoria',
'categorie.id',
];
$joins[] = [
'mg_categorie_lang AS categorie_lang' => 'mg_categorie_lang.id_record = categorie.id AND mg_categorie_lang.id_lang = '.setting('Lingua'),
'mg_articoli_lang' => 'mg_articoli_lang.id_record = mg_articoli.id AND mg_articoli_lang.id_lang = '.setting('Lingua'),
];
$joins[] = [
'mg_categorie AS sottocategorie',
'mg_articoli.id_sottocategoria',
'sottocategorie.id',
'`mg_categorie` AS categorie',
'`mg_articoli`.`id_categoria`',
'`categorie`.`id`',
];
$joins[] = [
'mg_categorie_lang AS sottocategorie_lang' => 'mg_categorie_lang.id_record = sottocategorie.id AND mg_categorie_lang.id_lang = '.setting('Lingua'),
'mg_categorie_lang AS categorie_lang' => '`mg_categorie_lang`.`id_record` = `categorie`.`id` AND `mg_categorie_lang`.`id_lang` = '.setting('Lingua'),
];
$joins[] = [
'`mg_categorie` AS sottocategorie',
'`mg_articoli`.`id_sottocategoria`',
'`sottocategorie`.`id`',
];
$where[] = ['mg_articoli.deleted_at', '=', null];
$joins[] = [
'`mg_categorie_lang` AS sottocategorie_lang' => '`mg_categorie_lang`.`id_record` = `sottocategorie`.`id` AND `mg_categorie_lang`.`id_lang` = '.setting('Lingua'),
];
$where[] = ['`mg_articoli`.`deleted_at`', '=', null];
$whereraw = [];
$order['mg_articoli.id'] = 'ASC';
$order['`mg_articoli`.`id`'] = 'ASC';
return [
'table' => $table,

View File

@ -32,6 +32,10 @@ class StatiContratti extends Resource implements RetrieveInterface
'*',
];
$joins[] = [
'co_staticontratti_lang' => '`co_staticontratti_lang`.`id_record` = `co_staticontratti`.`id` AND `co_staticontratti_lang`.`id_lang` = '.setting('Lingua'),
];
$where = $request['where'];
if (empty($where['deleted_at'])) {
$where['deleted_at'] = null;
@ -39,38 +43,10 @@ class StatiContratti extends Resource implements RetrieveInterface
return [
'select' => $select,
'joins' => $joins,
'table' => $table,
'where' => $where,
];
}
/**
* Ritorna l'attributo name dello stato contratto.
*
* @return string
*/
public function getNameAttribute()
{
return database()->table($this->table.'_lang')
->select('name')
->where('id_record', '=', $this->id)
->where('id_lang', '=', setting('Lingua'))
->first()->name;
}
/**
* Ritorna l'id dello stato contratto a partire dal nome.
*
* @param string $name il nome da ricercare
*
* @return \Illuminate\Support\Collection
*/
public function getByName($name)
{
return database()->table($this->table.'_lang')
->select('id_record')
->where('name', '=', $name)
->where('id_lang', '=', setting('Lingua'))
->first();
}
}

View File

@ -35,7 +35,7 @@ class StatiInterventi extends Resource implements RetrieveInterface
];
}
$join = [
$joins[] = [
'in_statiintervento_lang' => 'in_statiintervento_lang.id_record = in_statiintervento.id AND in_statiintervento_lang.id_lang = '.setting('Lingua'),
];
@ -47,7 +47,7 @@ class StatiInterventi extends Resource implements RetrieveInterface
return [
'select' => $select,
'table' => $table,
'join' => $join,
'joins' => $joins,
'where' => $where,
];
}

View File

@ -44,7 +44,7 @@ class StatiOrdini extends Resource implements RetrieveInterface
return [
'select' => $select,
'table' => $table,
'join' => $joins,
'joins' => $joins,
'where' => $where,
];
}

View File

@ -32,6 +32,10 @@ class StatiPreventivi extends Resource implements RetrieveInterface
'*',
];
$joins = [
'co_statipreventivi_lang' => 'co_statipreventivi_lang.id_record = co_statipreventivi.id AND co_statipreventivi_lang.id_lang = '.setting('Lingua'),
];
$where = $request['where'];
if (empty($where['deleted_at'])) {
$where['deleted_at'] = null;
@ -40,6 +44,7 @@ class StatiPreventivi extends Resource implements RetrieveInterface
return [
'select' => $select,
'table' => $table,
'joins' => $joins,
];
}
}

View File

@ -35,9 +35,14 @@ class TipiInterventi extends Resource implements RetrieveInterface
];
}
$joins = [
'in_tipiintervento_lang' => 'in_tipiintervento_lang.id_record = in_tipiintervento.id AND in_tipiintervento_lang.id_lang = '.setting('Lingua'),
];
return [
'select' => $select,
'table' => $table,
'joins' => $joins,
];
}
}