mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\SeasonalSegment;
|
|
use Illuminate\Console\Command;
|
|
use Carbon\Carbon;
|
|
use App\Classes\Modules\Companies\Services\RemovesCompanyFromSegment;
|
|
|
|
class RemoveSeasonalSegmentCompany extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'seasonalSegmantCompany:remove';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Perform soft delete on Seasonal Segment Company';
|
|
|
|
/** @var RemovesCompanyFromSegment */
|
|
private $removesCompanyFromSegment;
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(RemovesCompanyFromSegment $removesCompanyFromSegment)
|
|
{
|
|
parent::__construct();
|
|
$this->removesCompanyFromSegment = $removesCompanyFromSegment;
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$seasonalSegment = SeasonalSegment::where('ending_on', '<=', Carbon::today())->get();
|
|
|
|
if (count($seasonalSegment)){
|
|
foreach ($seasonalSegment as $seasonalSegmentCompany) {
|
|
$this->removesCompanyFromSegment->execute($seasonalSegmentCompany->company, $seasonalSegmentCompany->segment);
|
|
$seasonalSegmentCompany->delete();
|
|
$this->info(Carbon::now() . ' : Deleted id: ' . $seasonalSegmentCompany->id);
|
|
}
|
|
}
|
|
}
|
|
}
|