dazoapp is multi-tenant. Merchant data is separated by store_id (795 usages). Queries without scope = data leak across merchants.
// CORRECT
$bank = Bank::where('store_id', $store->store_id)->get();
// WRONG — leaks to all merchants
$bank = Bank::all();Key points (see Indonesian version for details):
- Get
$store_idviaauth()->user()->user_store->store_id— works for all roles (owner, CS, admin) - Do NOT use
$user->store— it only works for owners (returnsnullfor non-owners) - Always go through the
UserStorepivot table, even for owners, for consistency - Exception: if you already have
store_idfrom request/context, query Store directly - Eloquent relations do not inherit tenant scope — always scope explicitly
- In Jobs/Observers/Commands, pass
store_idexplicitly - Never use
Model::all()orModel::first()for tenant models