#Laravel passes download pass

1 messages · Page 1 of 1 (latest)

marsh elk
#
public function createApplePass(Request $request) {
        $uniqueId = uniqid();
    
        $pass = new GenericPass([
            'serialNumber' => $uniqueId,
            'description' => 'Card',
            'organizationName' => 'Card',
            'passTypeIdentifier' => '***',
            'teamIdentifier' => '***',
        ]);
    
        $barcode = new Barcode([
            'format' => 'PKBarcodeFormatQR',
            'message' => 'https://my-project.app/sample-url',
            'messageEncoding' => 'iso-8859-1',
        ]);
    
        $pass->barcodes = [$barcode];
        $pass->backgroundColor = 'rgb(0, 100, 255)';
        $pass->labelColor = 'rgb(255, 255, 255)';
        
        // dd(file_exists(storage_path("app/public/pass_files/pass.p12")));

        $logoPath = storage_path('app/public/img/layout/logo.png');
    
        if (file_exists($logoPath) && mime_content_type($logoPath) === 'image/png') {
            $pass->addImage(new Image($logoPath, ImageType::ICON, 1));
            $pass->addImage(new Image($logoPath, ImageType::LOGO, 1));
        } else {
            throw new \Exception('Icon and logo images must exist at ' . $logoPath . ' and be valid PNG files.');
        }
    
        $signedPass = $this->builder->apple()->create($pass);
        dd($signedPass);

        Storage::put('passes/pass.pkpass', $signedPass);
        return response($signedPass)
        ->header('Content-Type', 'application/vnd.apple.pkpass')
        ->header('Content-Disposition', 'attachment; filename="pass.pkpass"');

        // return response()->make($signedPass, 200, [
        //     'Content-Type' => 'application/vnd.apple.pkpass',
        //     'Content-Disposition' => 'attachment; filename="pass.pkpass"',
        // ]);
    }``` the code does not throw errors, it downloads a .pkpass file to your system. But instead, that it contains the code to generate a pass for apple, it contains something like 1sdf2334.pkpass as text, any idea?