app->bind( CategoryRepositoryInterface::class, function (Application $app) { /** @var CategoryRepository $repository */ $repository = app(CategoryRepository::class); if ($app->auth->check()) { $repository->setUser(auth()->user()); } return $repository; } ); } }