render invoice in pdf
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Order;
|
||||
use App\Repositories\Core\DateStats;
|
||||
use App\Repositories\Core\PDF;
|
||||
use App\Repositories\Shop\Customers;
|
||||
use App\Traits\Model\Basic;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -12,15 +14,34 @@ class Orders
|
||||
{
|
||||
use Basic, DateStats;
|
||||
|
||||
public static function getByUUID($uuid)
|
||||
public static function getPdfByUUID($uuid)
|
||||
{
|
||||
return Order::byUUID($uuid)->first();
|
||||
return self::getPdf(self::getIdByUUID($uuid), 'commande-' . $uuid . '.pdf');
|
||||
}
|
||||
|
||||
public static function getPdf($id, $file = 'order.pdf')
|
||||
{
|
||||
$data = [
|
||||
'order' => Orders::getFull($id),
|
||||
];
|
||||
|
||||
$customerId = Customers::getId();
|
||||
if ($customerId !== $data['order']['customer_id']) {
|
||||
return response()->view('errors.403');
|
||||
}
|
||||
|
||||
return PDF::view('Shop.Orders.view', $data, $file);
|
||||
}
|
||||
|
||||
public static function getFullByUUID($uuid)
|
||||
{
|
||||
return self::getFull(self::getIdByUUID($uuid));
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
return Order::with(['customer', 'delivery', 'delivery_address', 'detail', 'invoice.address', 'sale_channel'])
|
||||
->byUUID($uuid)->first();
|
||||
->byID($id)->first();
|
||||
}
|
||||
|
||||
public static function view($uuid)
|
||||
|
||||
Reference in New Issue
Block a user