finish implementing mails
This commit is contained in:
@@ -26,7 +26,7 @@ class Customers
|
||||
public static function editProfile($id = false)
|
||||
{
|
||||
$id = $id ? $id : self::getId();
|
||||
$orders_datatable = new CustomerOrdersDataTable;
|
||||
$orders_datatable = new CustomerOrdersDataTable();
|
||||
$data = [
|
||||
'customer' => self::get($id, ['addresses', 'deliveries', 'orders'])->toArray(),
|
||||
'deliveries' => Deliveries::getAll('sale_channel')->toArray(),
|
||||
@@ -144,7 +144,7 @@ class Customers
|
||||
return false;
|
||||
}
|
||||
$deliveries = collect($deliveries)->transform(
|
||||
function ($item, $key) {
|
||||
function ($item) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
|
||||
@@ -8,6 +8,20 @@ use App\Models\Shop\Invoice;
|
||||
|
||||
class Invoices
|
||||
{
|
||||
public static function getInvoiceHtml($id)
|
||||
{
|
||||
$invoice = self::get($id, ['order.customer', 'order.address', 'order.detail']);
|
||||
$order = $invoice->order;
|
||||
$customer = $order->customer;
|
||||
unset($invoice->order, $order->customer);
|
||||
$data = [
|
||||
'invoice' => $invoice->toArray(),
|
||||
'order' => $order->toArray(),
|
||||
'customer' => $customer->toArray(),
|
||||
];
|
||||
return view('Shop.Invoices.mail', $data)->render();
|
||||
}
|
||||
|
||||
public static function getByUUID($uuid)
|
||||
{
|
||||
return Invoice::byUUID($uuid)->first();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -9,28 +9,6 @@ use Illuminate\Mail\Mailables\Envelope;
|
||||
|
||||
trait MailCustomers
|
||||
{
|
||||
public static function getContext()
|
||||
{
|
||||
return Customers::getOptions();
|
||||
}
|
||||
|
||||
public static function getData($id)
|
||||
{
|
||||
$user = self::getUser($id);
|
||||
|
||||
return $user ? [
|
||||
'prenom' => $user->first_name,
|
||||
'nom' => $user->last_name,
|
||||
'societe' => $user->society,
|
||||
'email' => $user->email,
|
||||
] : false;
|
||||
}
|
||||
|
||||
public static function getUser($id)
|
||||
{
|
||||
return Customers::get($id);
|
||||
}
|
||||
|
||||
public function envelope()
|
||||
{
|
||||
return new Envelope(
|
||||
|
||||
Reference in New Issue
Block a user