From 4690c1db585f0f989a6eefb116bb3318074319c7 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 9 Feb 2017 14:43:17 +0200 Subject: [PATCH] create project --- app/library/App/Model/Project.php | 31 +++++++++++++++++++++++++++++++ app/library/App/Resources/ProjectResource.php | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 0 deletions(-) create mode 100644 app/library/App/Model/Project.php create mode 100644 app/library/App/Resources/ProjectResource.php diff --git a/app/library/App/Model/Project.php b/app/library/App/Model/Project.php new file mode 100644 index 0000000..b3611fc --- /dev/null +++ b/app/library/App/Model/Project.php @@ -0,0 +1,31 @@ + 'id', + 'name' => 'name', + 'user_id' => 'user_id' + ]; + } + + public function initialize() { + + $this->belongsTo('user_id', User::class, 'id', [ + 'alias' => 'User', + ]); + } +} diff --git a/app/library/App/Resources/ProjectResource.php b/app/library/App/Resources/ProjectResource.php new file mode 100644 index 0000000..887143f --- /dev/null +++ b/app/library/App/Resources/ProjectResource.php @@ -0,0 +1,39 @@ +name('Project') + ->model(Project::class) + ->expectsJsonData() + ->transformer(ModelTransformer::class) + ->itemKey('project') + ->collectionKey('projects') + ->deny(AclRoles::UNAUTHORIZED) + ->handler(CrudResourceController::class) + + ->endpoint(ApiEndpoint::all()) + ->endpoint(ApiEndpoint::create()) + ->endpoint(ApiEndpoint::find()) + ->endpoint(ApiEndpoint::update()) + ->endpoint(ApiEndpoint::remove()); + } + +} \ No newline at end of file -- libgit2 0.21.4