updated moon mailer
This commit is contained in:
@@ -15,6 +15,7 @@ use DB;
|
|||||||
use App\Models\Moon\Moon;
|
use App\Models\Moon\Moon;
|
||||||
use App\Models\Moon\MoonRent;
|
use App\Models\Moon\MoonRent;
|
||||||
use App\Models\Mail\EveMail;
|
use App\Models\Mail\EveMail;
|
||||||
|
use App\Models\Mail\SentMail;
|
||||||
|
|
||||||
class MoonMailerCommand extends Command
|
class MoonMailerCommand extends Command
|
||||||
{
|
{
|
||||||
@@ -63,6 +64,9 @@ class MoonMailerCommand extends Command
|
|||||||
//Get all of the moons from the rental list
|
//Get all of the moons from the rental list
|
||||||
$rentals = MoonRent::all();
|
$rentals = MoonRent::all();
|
||||||
|
|
||||||
|
//Get today's date.
|
||||||
|
$today = Carbon::now();
|
||||||
|
|
||||||
//Update the price for all moon rentals before sending out the mail
|
//Update the price for all moon rentals before sending out the mail
|
||||||
foreach($rentals as $rental) {
|
foreach($rentals as $rental) {
|
||||||
//Get the contents of the moon to re-price it out
|
//Get the contents of the moon to re-price it out
|
||||||
@@ -71,6 +75,7 @@ class MoonMailerCommand extends Command
|
|||||||
'Planet' => $rental->Planet,
|
'Planet' => $rental->Planet,
|
||||||
'Moon' => $rental->Moon,
|
'Moon' => $rental->Moon,
|
||||||
])->first();
|
])->first();
|
||||||
|
|
||||||
//Get the updated price for the moon
|
//Get the updated price for the moon
|
||||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||||
@@ -79,13 +84,13 @@ class MoonMailerCommand extends Command
|
|||||||
if($rental->Type == 'alliance') {
|
if($rental->Type == 'alliance') {
|
||||||
$body = "Moon Rent is due for " . $rental->System . " Planet: " . $rental->Planet . " Moon: " . $rental->Moon . "<br>";
|
$body = "Moon Rent is due for " . $rental->System . " Planet: " . $rental->Planet . " Moon: " . $rental->Moon . "<br>";
|
||||||
$body .= "The price for next month's rent is " . $price['alliance'] . "<br>";
|
$body .= "The price for next month's rent is " . $price['alliance'] . "<br>";
|
||||||
$body .= "Please remite payment to Spatial Forces by the 1st should you continue to wish to rent the moon.<br>";
|
$body .= "Please remit payment to Spatial Forces on the 1st should you continue to wish to rent the moon.<br>";
|
||||||
$body .= "Sincerely,<br>";
|
$body .= "Sincerely,<br>";
|
||||||
$body .= "Spatial Forces<br>";
|
$body .= "Spatial Forces<br>";
|
||||||
} else {
|
} else {
|
||||||
$body = "Moon Rent is due for " . $rental->System . " Planet: " . $rental->Planet . " Moon: " . $rental->Moon . "<br>";
|
$body = "Moon Rent is due for " . $rental->System . " Planet: " . $rental->Planet . " Moon: " . $rental->Moon . "<br>";
|
||||||
$body .= "The price for next month's rent is " . $price['outofalliance'] . "<br>";
|
$body .= "The price for next month's rent is " . $price['outofalliance'] . "<br>";
|
||||||
$body .= "Please remite payment to Spatial Forces by the 1st should you continue to wish to rent the moon.<br>";
|
$body .= "Please remit payment to Spatial Forces on the 1st should you continue to wish to rent the moon.<br>";
|
||||||
$body .= "Sincerely,<br>";
|
$body .= "Sincerely,<br>";
|
||||||
$body .= "Spatial Forces<br>";
|
$body .= "Spatial Forces<br>";
|
||||||
}
|
}
|
||||||
@@ -100,11 +105,20 @@ class MoonMailerCommand extends Command
|
|||||||
$mail->save();
|
$mail->save();
|
||||||
|
|
||||||
//Dispatch the job and cycle to the next moon rental
|
//Dispatch the job and cycle to the next moon rental
|
||||||
SendEveMail::dispatch($mail)->delay(Carbon::now()->addseconds(15));
|
SendEveMail::dispatch($mail)->delay(Carbon::now());
|
||||||
}
|
|
||||||
|
|
||||||
//Remove all moon rentals from the database
|
//After the mail is dispatched, saved the sent mail record,
|
||||||
DB::table('moon_rents')->delete();
|
$sentmail = new SentMail;
|
||||||
|
$sentmail = $mail->sender;
|
||||||
|
$sentmail = $mail->subject;
|
||||||
|
$sentmail = $mail->body;
|
||||||
|
$sentmail = $mail->recipient;
|
||||||
|
$sentmail = $mail->recipient_type;
|
||||||
|
$sentmail->save();
|
||||||
|
|
||||||
|
//After saving the record, delete the record from the database
|
||||||
|
MoonRent::where(['id' => $rental->id])->delete();
|
||||||
|
}
|
||||||
|
|
||||||
//Mark the job as finished
|
//Mark the job as finished
|
||||||
$task->SetStopStatus();
|
$task->SetStopStatus();
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class MoonsAdminController extends Controller
|
|||||||
//Going to store moon price in a table for future reference
|
//Going to store moon price in a table for future reference
|
||||||
//We need to insert a price based on whether part of Legacy or part of Warped Intentions
|
//We need to insert a price based on whether part of Legacy or part of Warped Intentions
|
||||||
//Will need an if then else statement to complete this operation
|
//Will need an if then else statement to complete this operation
|
||||||
if($allianceId = 99004116 || $allianceId = 99008072) {
|
if($allianceId = 99004116) {
|
||||||
MoonRent::insert([
|
MoonRent::insert([
|
||||||
'System' => $request->system,
|
'System' => $request->system,
|
||||||
'Planet' => $request->planet,
|
'Planet' => $request->planet,
|
||||||
|
|||||||
22
app/Models/Mail/SentMail.php
Normal file
22
app/Models/Mail/SentMail.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Mail;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class SentMail extends Model
|
||||||
|
{
|
||||||
|
//Table Name
|
||||||
|
protected $table = 'sent_mails';
|
||||||
|
|
||||||
|
//Timestamps
|
||||||
|
public $timestamps = 'false';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'sender',
|
||||||
|
'subject',
|
||||||
|
'body',
|
||||||
|
'recipient',
|
||||||
|
'recipient_type',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateSentMailsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('sent_mails', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('sender');
|
||||||
|
$table->string('subject');
|
||||||
|
$table->text('body');
|
||||||
|
$table->string('recipient');
|
||||||
|
$table->string('recipient_type');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('sent_mails');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user