Added command line send/reject for orders
This commit is contained in:
58
app/Console/Commands/OrderReject.php
Normal file
58
app/Console/Commands/OrderReject.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
use App\Mail\OrderRequestReject;
|
||||
use App\Models\Service;
|
||||
|
||||
class OrderReject extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'order:reject {service : Service ID} {reason : Reason }';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Reject Order';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$so = Service::findOrFail($this->argument('service'));
|
||||
|
||||
Mail::to($so->orderby->email)->sendNow(new OrderRequestReject($so,$this->argument('reason')));
|
||||
|
||||
if (Mail::failures()) {
|
||||
dump('Failure?');
|
||||
|
||||
dump(Mail::failures());
|
||||
}
|
||||
|
||||
$so->order_status = 'ORDER-REJECTED';
|
||||
$so->order_info = array_merge($so->order_info,['reason'=>$this->argument('reason')]);
|
||||
$so->save();
|
||||
}
|
||||
}
|
58
app/Console/Commands/OrderSend.php
Normal file
58
app/Console/Commands/OrderSend.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
use App\Mail\OrderRequestApprove;
|
||||
use App\Models\Service;
|
||||
|
||||
class OrderSend extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'order:send {service : Service ID}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send an order to a supplier';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$so = Service::findOrFail($this->argument('service'));
|
||||
|
||||
// @todo TO get from DB
|
||||
Mail::to('help@graytech.net.au')->sendNow(new OrderRequestApprove($so));
|
||||
|
||||
if (Mail::failures()) {
|
||||
dump('Failure?');
|
||||
|
||||
dump(Mail::failures());
|
||||
}
|
||||
|
||||
$so->order_status = 'ORDER-SENT';
|
||||
$so->save();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user