Once a pass is associated with one of your models (see Generating your first pass for how to wire that up), the HasMobilePasses trait gives you a few ways to fetch them back.
##Fetching Apple or Google passes
If you issue passes to both Apple Wallet and Google Wallet, the trait exposes dedicated helpers so you don't have to reach for $pass->platform yourself:
$user = User::first();
$user->applePasses;
$user->googlePasses;
$user->firstApplePass();
$user->firstGooglePass();
Both firstApplePass and firstGooglePass accept an optional PassType to narrow further:
use Spatie\LaravelMobilePass\Enums\PassType;
$user->firstApplePass(PassType::EventTicket);
##Fetching all passes
If you don't care about the platform, grab every pass tied to the model:
$mobilePasses = User::first()->mobilePasses;
For a single pass, use firstMobilePass:
$mobilePass = User::first()->firstMobilePass();
The firstMobilePass method takes an optional PassType to scope to a specific kind of pass, an optional Platform to cover both axes at once, and a filter closure for anything more custom:
use Spatie\LaravelMobilePass\Enums\PassType;
use Spatie\LaravelMobilePass\Enums\Platform;
$couponPass = User::first()->firstMobilePass(PassType::Coupon);
$appleEventTicket = User::first()->firstMobilePass(PassType::EventTicket, Platform::Apple);
$customQuery = User::first()->firstMobilePass(filter: function ($query) {
$query->where('type', PassType::Coupon);
});