The easiest way to download a pass is by returning a MobilePass model and return it from a controller.
class YourController
{
public function __invoke()
{
$pass = MobilePass::find(1);
return $pass;
}
}
This will return a response with the pass file and the correct headers to make it downloadable. The name of the pass will be pass.pkpass by default. You can change the name of the pass by specifying a download name when creating the mobile pass.
$mobilePass = AirlinePassBuilder::make()
->setDownloadName('boarding-pass-john-doe-to-london');
->setOrganisationName('My organisation')
-> ...
->save();
class YourController
{
public function __invoke()
{
$pass = MobilePass::find(1);
return $mobilePass;
}
}
You can also specify the download name when returning the pass from a controller.
$pass->download('custom-pass-download-name');