Fix printMultiProductSheet

making 2 sheets for the firs product item
This commit is contained in:
Jérémy Munsch 2023-09-11 11:28:07 +02:00
parent 6aab7d4eff
commit c88583d727
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
2 changed files with 8 additions and 9 deletions

View file

@ -28,7 +28,6 @@ class ProductController extends Controller
*/
public function index(IndexFilterRequest $request)
{
// DB::enableQueryLog();
/** @var \Illuminate\Database\Eloquent\Builder $brands */
$brandsQuery = Brand::query();
@ -40,7 +39,6 @@ class ProductController extends Controller
$this->sortQuery($productsQuery);
$products = $this->paginate($productsQuery);
// dd(DB::getQueryLog(), $products->items());
/** @var array $printMultiProduct Array of id */
$printMultiProduct = session('printMultiProduct') ?? [];
@ -320,6 +318,7 @@ class ProductController extends Controller
*/
public function printMultiProductSheet()
{
// FIXME: This should not use session.
/** @var array printMultiProduct */
$printMultiProduct = session('printMultiProduct') ?? [];
asort($printMultiProduct);

View file

@ -319,14 +319,14 @@ class Product extends Model
// * If not yet defined, set the first page.
if (is_null($pdf)) {
$pdf = Product::generateProductPdf($product, $title);
} else {
// * Add another page and add HTML from view to this.
$pdf->getMpdf()->AddPage();
$pdf->getMpdf()->WriteHTML((string)view(
'documents.product-body',
['product' => (object)(new ProductResource($product))->toArray()],
));
}
// * Add another page and add HTML from view to this.
$pdf->getMpdf()->AddPage();
$pdf->getMpdf()->WriteHTML((string)view(
'documents.product-body',
['product' => (object)(new ProductResource($product))->toArray()],
));
}
return $pdf;
}