aa
This commit is contained in:
@@ -51,7 +51,7 @@ class ProductUpdateGm extends Command
|
||||
set_time_limit(0);
|
||||
ini_set("memory_limit", "512M");
|
||||
$settingora = Setting::where('key', 'update_products')->first();
|
||||
$productLogger = new ProductLogger($settingora->value);
|
||||
$productLogger = new ProductLogger($settingora);
|
||||
echo "SettingOra: " . $settingora;
|
||||
$fromtime = str_replace('-', '', $settingora->value);
|
||||
|
||||
|
||||
@@ -1515,7 +1515,7 @@ function getArticoloById($idarticolo) {
|
||||
|
||||
function updateArticoloFromGM($idarticolo)
|
||||
{
|
||||
$productLogger = new ProductLogger("");
|
||||
$productLogger = new ProductLogger(null);
|
||||
|
||||
try {
|
||||
$articles = Article::join(DB::raw('(SELECT IdArticolo, MAX(DataOra) AS data FROM T_WEB_Articoli GROUP BY IdArticolo) b'), function ($join) {
|
||||
|
||||
@@ -12,13 +12,13 @@ use App\Mylog;
|
||||
class ProductLogger
|
||||
{
|
||||
public $logs = [];
|
||||
protected $settingOra;
|
||||
protected $settingOra = null;
|
||||
|
||||
protected $aggiornato = false;
|
||||
|
||||
public function __construct($settingOraValue)
|
||||
public function __construct($settingOra)
|
||||
{
|
||||
$this->settingOra = $settingOraValue;
|
||||
$this->settingOra = $settingOra;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class ProductLogger
|
||||
{
|
||||
$oraUpdate = Carbon::now();
|
||||
if ($this->settingOra) {
|
||||
$this->logs['start'] = 'Inizio da ' . $this->settingOra . "\n<br>";
|
||||
$this->logs['start'] = 'Inizio da ' . $this->settingOra->value . "\n<br>";
|
||||
$this->logs['end'] = 'Fino a ' . $oraUpdate->toDateTimeString() . "\n<br>";
|
||||
} else {
|
||||
$this->logs['start'] = 'Iniziato: ' . $oraUpdate->toDateTimeString() . "\n<br>";
|
||||
@@ -46,9 +46,15 @@ class ProductLogger
|
||||
|
||||
public function setLogandSendEmail()
|
||||
{
|
||||
if ($this->settingOra) {
|
||||
if (is_object($this->settingOra) && method_exists($this->settingOra, 'save')) {
|
||||
$ora_update = Carbon::now();
|
||||
$this->settingOra->value = $ora_update->toDateTimeString();
|
||||
$this->settingOra->save();
|
||||
} else {
|
||||
// Gestisci il caso in cui $this->settingOra non è un oggetto o non ha il metodo save
|
||||
Log::warning('Impossibile eseguire il metodo save() su $this->settingOra, non è un oggetto o il metodo non esiste.');
|
||||
}
|
||||
|
||||
if ($this->aggiornato) {
|
||||
Log::channel('updateproducts')->notice($this->concatenateLogs());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user