hasMany(Order::class); } /** * Logic Booted untuk Multi-Tenancy */ protected static function booted() { static::addGlobalScope('owner', function (Builder $builder) { if (Auth::check()) { $user = Auth::user(); $ownerId = $user->getOwnerId(); $builder->where('user_id', $ownerId); } }); static::creating(function ($service) { if (Auth::check()) { $user = Auth::user(); $service->user_id = $user->getOwnerId(); } }); } }