Added dynamic logic in pdf controller
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Successful in 20s
Laravel Pint / pint (pull_request) Failing after 4m34s
Laravel Larastan / larastan (pull_request) Failing after 4m49s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Successful in 20s
Laravel Pint / pint (pull_request) Failing after 4m34s
Laravel Larastan / larastan (pull_request) Failing after 4m49s
This commit is contained in:
@@ -4,8 +4,10 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\GrMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\ItemCharacteristic;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use App\Models\StickerDetail;
|
||||
use App\Models\StickerStructureDetail;
|
||||
use App\Models\User;
|
||||
use App\Services\StickerPdfService;
|
||||
@@ -893,25 +895,60 @@ class PdfController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
public function generate(string $stickerId)
|
||||
{
|
||||
// public function generate(string $stickerId)
|
||||
// {
|
||||
|
||||
// $stickerId = trim($stickerId);
|
||||
|
||||
// $elements = StickerStructureDetail::where('sticker_id', $stickerId)
|
||||
// ->first();
|
||||
|
||||
// $pdfService = new StickerPdfService();
|
||||
// return $pdfService->generate($stickerId, $elements->toArray());
|
||||
// }
|
||||
|
||||
public function generate(Request $request, $stickerId)
|
||||
{
|
||||
$plantId = $request->query('plant_id');
|
||||
$itemCharacteristicId = $request->query('item_characteristic_id');
|
||||
$stickerId = trim($stickerId);
|
||||
|
||||
$elements = StickerStructureDetail::where('sticker_id', $stickerId)
|
||||
->first();
|
||||
if ($plantId && $itemCharacteristicId)
|
||||
{
|
||||
$plantId = $request->query('plant_id');
|
||||
$itemCharacteristicId = $request->query('item_characteristic_id');
|
||||
|
||||
if (!$elements) {
|
||||
Notification::make()
|
||||
->title('Sticker not found')
|
||||
->body("Sticker ID '{$stickerId}' does not exist.")
|
||||
->danger()
|
||||
->send();
|
||||
$sticId = StickerStructureDetail::where('sticker_id', $stickerId)->first();
|
||||
|
||||
return;
|
||||
$sId = $sticId->id;
|
||||
|
||||
$dynamicElements = StickerDetail::where('sticker_structure_detail_id', $sId)
|
||||
->where('element_type', 'Dynamic')
|
||||
->get();
|
||||
|
||||
$itemCharacteristic = null;
|
||||
|
||||
if ($plantId && $itemCharacteristicId) {
|
||||
$itemCharacteristic = ItemCharacteristic::where('plant_id', $plantId)
|
||||
->where('id', $itemCharacteristicId)
|
||||
->first();
|
||||
}
|
||||
|
||||
$pdfService = new StickerPdfService();
|
||||
|
||||
return $pdfService->generate1(
|
||||
$stickerId,
|
||||
$dynamicElements,
|
||||
$itemCharacteristic
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$elements = StickerStructureDetail::where('sticker_id', $stickerId)
|
||||
->first();
|
||||
|
||||
$pdfService = new StickerPdfService();
|
||||
return $pdfService->generate($stickerId, $elements->toArray());
|
||||
$pdfService = new StickerPdfService();
|
||||
return $pdfService->generate($stickerId, $elements->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user