moon mailer
This commit is contained in:
42
app/Console/Commands/UpdateMoonRental.php
Normal file
42
app/Console/Commands/UpdateMoonRental.php
Normal 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()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user