This commit is contained in:
paoloar77
2024-05-17 14:34:41 +02:00
parent 21e590a301
commit 1b77e57224
2 changed files with 82 additions and 5 deletions

View File

@@ -0,0 +1,78 @@
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Codexshaper\WooCommerce\Facades\Product;
use Illuminate\Console\Command;
use App\Setting;
use App\Article;
use App\Mylog;
use App\Stock;
use Codexshaper\WooCommerce\Models\Product as ModelsProduct;
use Codexshaper\WooCommerce\Facades\Variation;
use Codexshaper\WooCommerce\Facades\Category;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\DB;
class TestPao extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'product:startday';
/**
* The console command description.
*
* @var string
*/
protected $description = 'STARTDAY:';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
try {
$log = "*** STARTDAY: ";
$log .= "************** FINE *********** ";
// Select all the fields of the Stock table
} catch (\Exception $e) {
$log .= $e->getMessage();
echo "Error: " . $e->getMessage();
}
echo $log;
Log::channel('testpao')->notice($log);
if (true) {
// Send the email
Mail::raw($log, function ($message) {
$message->to(Mylog::getEmail());
$message->subject(Mylog::getSubjectEmail("STARTDAY"));
});
}
}
}

View File

@@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
Log::info('Controllo schedule...');
// $schedule->command('inspire')->hourly();
$schedule->command('backup:clean')->daily()->at('02:00')->before(function () {
@@ -46,11 +46,10 @@ class Kernel extends ConsoleKernel
$schedule->command('product:updateqta')->everyFiveMinutes()->between('8:00', '00:00')->withoutOverlapping()->before(function () {
Log::info('Running product:updateqta command');
});
$schedule->command('product:testpao')
->everyFiveMinutes()
->between('8:00', '00:00')
$schedule->command('product:startday')
->daily()->at('08:00')
->before(function () {
Log::info('Running product:testpao command');
Log::info('Running product:startday command');
});
}