log
This commit is contained in:
109
app/Article.php
109
app/Article.php
@@ -8,74 +8,71 @@ class Article extends Model
|
||||
{
|
||||
protected $table = 'T_WEB_Articoli';
|
||||
|
||||
/*
|
||||
/*
|
||||
public function authors()
|
||||
{
|
||||
return $this->hasMany(Author::class);
|
||||
}
|
||||
*/
|
||||
|
||||
public function getAuthorsAttribute()
|
||||
{
|
||||
$authorId = $this->getRawOriginal('ListaAutori');
|
||||
$ids = explode(",",$authorId);
|
||||
$autori = [];
|
||||
foreach ($ids as $id)
|
||||
public function getAuthorsAttribute()
|
||||
{
|
||||
$authorId = $this->getRawOriginal('ListaAutori');
|
||||
$ids = explode(",", $authorId);
|
||||
$autori = [];
|
||||
foreach ($ids as $id) {
|
||||
|
||||
$autore = Author::where('IdAutore',$id)->orderBy('DataOra', 'desc')->first();
|
||||
if($autore){
|
||||
//$autori[] = ($autore->Nome != '' ? trim($autore->Nome) . " " : '') . trim($autore->Cognome);
|
||||
$autori[] = trim($autore->Nome) . "," . trim($autore->Cognome);
|
||||
$autore = Author::where('IdAutore', $id)->orderBy('DataOra', 'desc')->first();
|
||||
if ($autore) {
|
||||
//$autori[] = ($autore->Nome != '' ? trim($autore->Nome) . " " : '') . trim($autore->Cognome);
|
||||
$autori[] = trim($autore->Nome) . "," . trim($autore->Cognome);
|
||||
}
|
||||
}
|
||||
|
||||
return $autori;
|
||||
}
|
||||
|
||||
public function getStockAttribute()
|
||||
{
|
||||
$qtas = Stock::where('Codice', $this->IdArticolo)->orderBy('DataOra', 'desc');
|
||||
if ($qtas->count() > 0) {
|
||||
$qta = $qtas->first();
|
||||
$disponibilita = $qta->QtaDisponibile;
|
||||
} else {
|
||||
$disponibilita = 0;
|
||||
}
|
||||
return $disponibilita;
|
||||
}
|
||||
public function getStatoprodottoAttribute()
|
||||
{
|
||||
$status = Statusproduct::where('IdStatoProdotto', $this->IdStatoProdotto)->orderBy('DataOra', 'desc')->first();
|
||||
return $status->Descrizione;
|
||||
}
|
||||
|
||||
public function getEditoreAttribute()
|
||||
{
|
||||
if ($this->IdMarchioEditoriale > 0) {
|
||||
$editore = Publisher::where('IdMarchioEditoriale', $this->IdMarchioEditoriale)->orderBy('DataOra', 'desc')->first();
|
||||
return $editore->Descrizione;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $autori;
|
||||
}
|
||||
|
||||
public function getStockAttribute()
|
||||
{
|
||||
$qtas = Stock::where('Codice', $this->IdArticolo)->orderBy('DataOra', 'desc');
|
||||
if($qtas->count() > 0 ){
|
||||
$qta = $qtas->first();
|
||||
$disponibilita = $qta->QtaDisponibile;
|
||||
} else {
|
||||
$disponibilita = 0;
|
||||
public function getArgomentoAttribute()
|
||||
{
|
||||
$argomenti = Category::where('IdArgomento', $this->ListaArgomenti)->orderBy('DataOra', 'desc');
|
||||
if ($argomenti->count() > 0) {
|
||||
$argomento = $argomenti->first();
|
||||
$descrizione = $argomento->Descrizione;
|
||||
} else {
|
||||
$descrizione = "Nessuna categoria";
|
||||
}
|
||||
return $descrizione;
|
||||
}
|
||||
return $disponibilita;
|
||||
}
|
||||
public function getStatoprodottoAttribute()
|
||||
{
|
||||
$status = Statusproduct::where('IdStatoProdotto', $this->IdStatoProdotto)->orderBy('DataOra', 'desc')->first();
|
||||
return $status->Descrizione;
|
||||
}
|
||||
|
||||
public function getEditoreAttribute()
|
||||
{
|
||||
if($this->IdMarchioEditoriale > 0){
|
||||
$editore = Publisher::where('IdMarchioEditoriale', $this->IdMarchioEditoriale)->orderBy('DataOra', 'desc')->first();
|
||||
return $editore->Descrizione;
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
public function nimaia()
|
||||
{
|
||||
return $this->hasOne('App\Artnim', 'id_gm', 'IdArticolo');
|
||||
}
|
||||
}
|
||||
|
||||
public function getArgomentoAttribute()
|
||||
{
|
||||
$argomenti = Category::where('IdArgomento', $this->ListaArgomenti)->orderBy('DataOra', 'desc');
|
||||
if($argomenti->count() > 0){
|
||||
$argomento = $argomenti->first();
|
||||
$descrizione = $argomento->Descrizione;
|
||||
} else {
|
||||
$descrizione = "Nessuna categoria";
|
||||
}
|
||||
return $descrizione;
|
||||
}
|
||||
|
||||
public function nimaia()
|
||||
{
|
||||
return $this->hasOne('App\Artnim', 'id_gm', 'IdArticolo' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user