23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
73
app/Mail/MailDhlTracking.php
Normal file
73
app/Mail/MailDhlTracking.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Acme\Dhl\Models\DhlShipment;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\Util;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class MailDhlTracking extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $shipments;
|
||||
|
||||
protected $order;
|
||||
|
||||
public $subject;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param DhlShipment|Collection $shipments Single shipment or collection of shipments
|
||||
* @param ShoppingOrder $order
|
||||
*/
|
||||
public function __construct($shipments, ShoppingOrder $order)
|
||||
{
|
||||
// Accept both single shipment and collection
|
||||
if ($shipments instanceof DhlShipment) {
|
||||
$this->shipments = collect([$shipments]);
|
||||
} else {
|
||||
$this->shipments = $shipments;
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
|
||||
// Adjust subject based on number of shipments
|
||||
if ($this->shipments->count() > 1) {
|
||||
$this->subject = __('email.dhl_tracking_subject_multiple', ['count' => $this->shipments->count()]);
|
||||
} else {
|
||||
$this->subject = __('email.dhl_tracking_subject');
|
||||
}
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$shoppingUser = $this->order->shopping_user;
|
||||
|
||||
$salutation = __('email.hello');
|
||||
if ($shoppingUser && $shoppingUser->billing_firstname) {
|
||||
$salutation = __('email.hello') . ' ' . $shoppingUser->billing_firstname;
|
||||
}
|
||||
|
||||
// For backward compatibility, also provide single shipment data
|
||||
$primaryShipment = $this->shipments->first();
|
||||
|
||||
return $this->view('emails.dhl_tracking')->with([
|
||||
'salutation' => $salutation,
|
||||
'shipments' => $this->shipments,
|
||||
'shipment' => $primaryShipment, // Backward compatibility
|
||||
'order' => $this->order,
|
||||
'trackingNumber' => $primaryShipment->dhl_shipment_no, // Backward compatibility
|
||||
'trackingUrl' => $primaryShipment->getTrackingUrl(), // Backward compatibility
|
||||
'orderNumber' => $this->order->getLastShoppingPayment('reference'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
'url' => Util::getMyMivitaUrl(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue