commands and job

This commit is contained in:
2020-07-26 01:14:22 -05:00
parent cf98e875ee
commit 8cf4c98633
4 changed files with 73 additions and 3 deletions
@@ -2,7 +2,16 @@
namespace App\Console\Commands\SupplyChain;
//Internal Library
use Illuminate\Console\Command;
use Log;
use Carbon\Carbon;
//Models
use App\Models\Contracts\SupplyChainContract;
//Job
use App\Jobs\Commands\SupplyChain\EndSupplyChainContractJob;
class EndSupplyChainContractCommand extends Command
{
@@ -37,6 +46,16 @@ class EndSupplyChainContractCommand extends Command
*/
public function handle()
{
//
$today = Carbon::now();
//Get the supply chain contracts which are open, but need to be closed.
$contracts = SupplyChainContract::where([
'state' => 'open',
])->where('end_date', '>', $today)->get();
//Create jobs to complete each contract
foreach($contracts as $contract) {
EndSupplyChainContractJob::dispatch($contract)->onQueue('default');
}
}
}