moon mailer

This commit is contained in:
2019-05-06 12:34:11 -05:00
parent b0e193274f
commit 7b0165be83
2 changed files with 44 additions and 15 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class UpdateMoonRental extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:UpdateMoonRental';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}

View File

@@ -111,30 +111,17 @@ class MoonMailerCommand extends Command
//After the mail is dispatched, saved the sent mail record
$this->SaveSentRecord($mail->sender, $mail->subject, $mail->body, $mail->recipient, $mail->recipient_type);
//Delete the record from the database
//Update the moon as not being paid for the next month?
foreach($rentals as $rental) {
//Delete the moon rental
$this->DeleteMoonRental($rental, $today);
//Mark the moon as not paid for the next month
$this->UpdateNotPaid($rental);
}
}
//Mark the job as finished
$task->SetStopStatus();
}
private function DeleteMoonRent(MoonRental $rental, Carbon $today) {
if($today->greaterThanOrEqualTo($rental->RentalEnd)) {
MoonRental::where(['id' => $rental->id])->delete();
}
}
private function PaidUntil(MoonRental $rental) {
return $rental->paid_until;
}
private function UpdateNotPaid(MoonRental $rental) {
$today = Carbon::now();