From ff0bc8f6afd9cff16232a7afd455ac6639bc48da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Fri, 22 Nov 2024 19:49:21 +0100 Subject: [PATCH] wip --- resources.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/resources.md b/resources.md index ec6581e..5d05eff 100644 --- a/resources.md +++ b/resources.md @@ -20,26 +20,30 @@ php artisan root:resource CustomPostResource --model=Post ## Registering Resources -You may register your resources by using the `RootServiceProvider` which is published and automatically registered when the `root:install` artisan command is called. +Root automatically registers the resources found in the `app/Root/Resources` directory. However you may store resources somewhere else or also you may want to register a resource manually: ```php namespace App\Providers; -use App\Root\Resources\PostResource; -use App\Root\Resources\UserResource; -use Cone\Root\RootApplicationServiceProvider; +use Cone\Root\Root; +use Illuminate\Support\ServiceProvider; -class RootServiceProvider extends RootApplicationServiceProvider +class AppServiceProvider extends ServiceProvider { /** - * The resources. + * Bootstrap any application services. */ - protected function resources(): array + public function boot(): void { - return [ - new UserResource, - new PostResource, - ]; + // Discover in custom directory + Root::instance()->resources->discoverIn([ + app_path('Path/To/Resources'), + ]); + + // Register manually + Root::instance()->resources->register([ + new \App\Root\Resources\ProductResource, + ]); } } ```