finish implementing mails
This commit is contained in:
@@ -26,11 +26,21 @@ class CategoryController extends Controller
|
||||
dump($product_type);
|
||||
exit;
|
||||
} else {
|
||||
// $product_type = Articles::getProductTypeByCategory($category_id);
|
||||
// dump($product_type);
|
||||
$article_nature = $request->input('article_nature');
|
||||
// dump($article_nature);
|
||||
// exit;
|
||||
if (!$article_nature) {
|
||||
$article_natures = Articles::getArticleNaturesWithOffers([
|
||||
'category_id' => $category_id,
|
||||
]);
|
||||
if (count($article_natures) === 1) {
|
||||
$article_nature = $article_natures[0];
|
||||
}
|
||||
$product_types = Articles::getProductTypesWithOffers([
|
||||
'category_id' => $category_id,
|
||||
]);
|
||||
if (count($product_types) === 1) {
|
||||
$product_type = $product_types[0];
|
||||
}
|
||||
}
|
||||
|
||||
switch ($article_nature) {
|
||||
case 'semences':
|
||||
@@ -46,14 +56,17 @@ class CategoryController extends Controller
|
||||
$article_nature_id = 3;
|
||||
break;
|
||||
default:
|
||||
$product_type = 'botanic';
|
||||
$article_nature_id = 1;
|
||||
$article_nature = 'semences';
|
||||
if (!($product_type ?? false)) {
|
||||
$product_type = 'botanic';
|
||||
$article_nature_id = 1;
|
||||
$article_nature = 'semences';
|
||||
}
|
||||
break;
|
||||
}
|
||||
// $product_type = ArticleNatures::getProductType($article_nature_id);
|
||||
// dump($product_type);
|
||||
// dump($article_nature_id);
|
||||
// exit;
|
||||
}
|
||||
// exit;
|
||||
$data = [
|
||||
@@ -62,12 +75,8 @@ class CategoryController extends Controller
|
||||
'display_by_rows' => $request->input('display_by_rows') ?? false,
|
||||
'product_type' => $product_type,
|
||||
'article_nature' => $article_nature,
|
||||
'article_natures' => Articles::getArticleNaturesWithOffers([
|
||||
'category_id' => $category_id,
|
||||
]),
|
||||
'product_types' => Articles::getProductTypesWithOffers([
|
||||
'category_id' => $category_id,
|
||||
]),
|
||||
'article_natures' => $article_natures,
|
||||
'product_types' => $product_types,
|
||||
'tags_selected' => $request->input('tags') ?? [],
|
||||
'articles' => Articles::getArticlesToSell([
|
||||
'category_id' => $category_id,
|
||||
@@ -77,6 +86,8 @@ class CategoryController extends Controller
|
||||
]),
|
||||
'tags' => TagGroups::getWithTagsAndCountOffers($category_id),
|
||||
];
|
||||
// dump($data);
|
||||
// exit;
|
||||
return view('Shop.Shelves.shelve', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Core\Mail\MailTemplate;
|
||||
use App\Repositories\Shop\Invoices;
|
||||
use App\Repositories\Shop\Traits\MailCustomers;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
@@ -14,18 +15,42 @@ class Acheminement extends TemplateMailable
|
||||
|
||||
protected static $templateModelClass = MailTemplate::class;
|
||||
|
||||
public $user;
|
||||
public $email;
|
||||
|
||||
public $male;
|
||||
public $nom;
|
||||
|
||||
public $prenom;
|
||||
|
||||
public $societe;
|
||||
|
||||
public $subject;
|
||||
|
||||
public $url;
|
||||
public $numero_suivi;
|
||||
|
||||
public function __construct($user, $subject = '')
|
||||
public $numero_commande;
|
||||
|
||||
public $adresse;
|
||||
|
||||
public $cp;
|
||||
|
||||
public $ville;
|
||||
|
||||
public $date_expedition;
|
||||
|
||||
public $facture;
|
||||
|
||||
public function __construct($order)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->male = $user->gender == 1;
|
||||
$this->subject = $subject;
|
||||
$this->prenom = $order->customer->first_name;
|
||||
$this->nom = $order->customer->last_name;
|
||||
$this->adresse = $order->address->address;
|
||||
$this->cp = $order->address->zipcode;
|
||||
$this->ville = $order->address->city;
|
||||
$this->societe = $order->customer->company;
|
||||
$this->email = $order->customer->email;
|
||||
$this->numero_suivi = $order->delivery_ref;
|
||||
$this->numero_commande = $order->ref;
|
||||
$this->date_expedition = $order->updated_at;
|
||||
$this->facture = Invoices::getInvoiceHtml($order->invoice->id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ class Preparation extends TemplateMailable
|
||||
|
||||
public $subject;
|
||||
|
||||
public function __construct($user, $subject = '')
|
||||
public function __construct($order)
|
||||
{
|
||||
$this->prenom = $user->first_name;
|
||||
$this->nom = $user->last_name;
|
||||
$this->societe = $user->society;
|
||||
$this->email = $user->email;
|
||||
$this->prenom = $order->customer->first_name;
|
||||
$this->nom = $order->customer->last_name;
|
||||
$this->societe = $order->customer->company;
|
||||
$this->email = $order->customer->email;
|
||||
$this->subject = $subject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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