diff --git a/app/library/App/Model/Project.php b/app/library/App/Model/Project.php new file mode 100644 index 0000000..bd78b43 --- /dev/null +++ b/app/library/App/Model/Project.php @@ -0,0 +1,39 @@ + 'id', + 'name' => 'name', + 'user_id' => 'user_id' + ]; + } + + public function initialize() { + + $this->belongsTo('user_id', User::class, 'id', [ + 'alias' => 'User', + ]); + } + +} \ No newline at end of file diff --git a/app/library/App/Resources/ProjectResource.php b/app/library/App/Resources/ProjectResource.php new file mode 100644 index 0000000..a122352 --- /dev/null +++ b/app/library/App/Resources/ProjectResource.php @@ -0,0 +1,44 @@ +name('Project') + ->model(Project::class) + ->expectsJsonData() + ->transformer(ProjectTransformer::class) + ->handler(CrudResourceController::class) + ->itemKey('project') + ->collectionKey('projects') + ->deny(AclRoles::UNAUTHORIZED) + + ->endpoint(ApiEndpoint::all() + ->description('Returns all projects') + ) + ->endpoint(ApiEndpoint::create()) + ->endpoint(ApiEndpoint::find()) + ->endpoint(ApiEndpoint::update()) + ->endpoint(ApiEndpoint::remove()); + + } + +} \ No newline at end of file diff --git a/app/library/App/Transformers/ProjectTransformer.php b/app/library/App/Transformers/ProjectTransformer.php new file mode 100644 index 0000000..8609b8f --- /dev/null +++ b/app/library/App/Transformers/ProjectTransformer.php @@ -0,0 +1,18 @@ +