finish implementing mails

This commit is contained in:
Ludovic CANDELLIER
2023-04-17 00:27:03 +02:00
parent 6649c32501
commit b283363543
8 changed files with 274 additions and 49 deletions

View File

@@ -3,10 +3,13 @@
namespace App\Repositories\Shop;
use Carbon\Carbon;
use App\Mail\Acheminement;
use App\Mail\Preparation;
use App\Models\Shop\Order;
use App\Repositories\Core\DateStats;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Mail;
class Orders
{
@@ -34,6 +37,35 @@ class Orders
return ($order && $detail) ? Invoices::saveInvoice($order->id, $data) : false;
}
public static function testSend($id)
{
$order = self::get($id, ['customer', 'address']);
dump($order->toArray());
exit;
self::sendPreparation($order);
}
public static function sendOrderConfirmed($order_id)
{
$order = self::get($order_id, ['customer']);
$mail = new Acheminement($order);
return Mail::to($order->email)->send($mail);
}
public static function sendShipping($order_id)
{
$order = self::get($order_id, ['customer']);
$mail = new Acheminement($order);
return Mail::to($order->email)->send($mail);
}
public static function sendPreparation($order_id)
{
$order = self::get($order_id, ['customer']);
$mail = new Preparation($order);
return Mail::to($order->email)->send($mail);
}
public static function count()
{
return Order::count();