-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added billable rates; Added project members; Added visibility to proj…
…ects
- Loading branch information
Showing
72 changed files
with
3,401 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ yarn-error.log | |
/playwright/.cache/ | ||
/coverage | ||
/extensions/* | ||
/modules_statuses.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/Exceptions/Api/TimeEntryCanNotBeRestartedApiException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Exceptions\Api; | ||
|
||
class TimeEntryCanNotBeRestartedApiException extends ApiException | ||
{ | ||
public const string KEY = 'time_entry_can_not_be_restarted'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
app/Http/Controllers/Api/V1/ProjectMemberController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers\Api\V1; | ||
|
||
use App\Http\Requests\V1\ProjectMember\ProjectMemberStoreRequest; | ||
use App\Http\Requests\V1\ProjectMember\ProjectMemberUpdateRequest; | ||
use App\Http\Resources\V1\ProjectMember\ProjectMemberCollection; | ||
use App\Http\Resources\V1\ProjectMember\ProjectMemberResource; | ||
use App\Models\Organization; | ||
use App\Models\Project; | ||
use App\Models\ProjectMember; | ||
use Illuminate\Auth\Access\AuthorizationException; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class ProjectMemberController extends Controller | ||
{ | ||
protected function checkPermission(Organization $organization, string $permission, ?Project $project = null, ?ProjectMember $projectMember = null): void | ||
{ | ||
parent::checkPermission($organization, $permission); | ||
if ($project !== null && $project->organization_id !== $organization->id) { | ||
throw new AuthorizationException('Project does not belong to organization'); | ||
} | ||
if ($projectMember !== null && $projectMember->project->organization_id !== $organization->id) { | ||
throw new AuthorizationException('Project member does not belong to organization'); | ||
} | ||
} | ||
|
||
/** | ||
* Get project members for project | ||
* | ||
* @return ProjectMemberCollection<ProjectMemberResource> | ||
* | ||
* @throws AuthorizationException | ||
* | ||
* @operationId getProjectMembers | ||
*/ | ||
public function index(Organization $organization, Project $project): ProjectMemberCollection | ||
{ | ||
$this->checkPermission($organization, 'project-members:view', $project); | ||
|
||
$projectMembers = ProjectMember::query() | ||
->whereBelongsTo($project, 'project') | ||
->paginate(); | ||
|
||
return new ProjectMemberCollection($projectMembers); | ||
} | ||
|
||
/** | ||
* Add project member to project | ||
* | ||
* @throws AuthorizationException | ||
* | ||
* @operationId createProjectMember | ||
*/ | ||
public function store(Organization $organization, Project $project, ProjectMemberStoreRequest $request): JsonResource | ||
{ | ||
$this->checkPermission($organization, 'project-members:create', $project); | ||
$projectMember = new ProjectMember(); | ||
$projectMember->user_id = $request->input('user_id'); | ||
$projectMember->billable_rate = $request->input('billable_rate'); | ||
$projectMember->project()->associate($project); | ||
$projectMember->save(); | ||
|
||
return new ProjectMemberResource($projectMember); | ||
} | ||
|
||
/** | ||
* Update project member | ||
* | ||
* @throws AuthorizationException | ||
* | ||
* @operationId updateProjectMember | ||
*/ | ||
public function update(Organization $organization, ProjectMember $projectMember, ProjectMemberUpdateRequest $request): JsonResource | ||
{ | ||
$this->checkPermission($organization, 'project-members:update', projectMember: $projectMember); | ||
$projectMember->billable_rate = $request->input('billable_rate'); | ||
$projectMember->save(); | ||
|
||
return new ProjectMemberResource($projectMember); | ||
} | ||
|
||
/** | ||
* Delete project member | ||
* | ||
* @throws AuthorizationException | ||
* | ||
* @operationId deleteProjectMember | ||
*/ | ||
public function destroy(Organization $organization, ProjectMember $projectMember): JsonResponse | ||
{ | ||
$this->checkPermission($organization, 'project-members:delete', projectMember: $projectMember); | ||
|
||
$projectMember->delete(); | ||
|
||
return response() | ||
->json(null, 204); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.