-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
4,581 additions
and
35 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
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
134 changes: 134 additions & 0 deletions
134
app/Http/Controllers/Company/Project/ProjectTaskListsController.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,134 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Company\Project; | ||
|
||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
use Illuminate\Http\Request; | ||
use App\Helpers\InstanceHelper; | ||
use App\Models\Company\Project; | ||
use Illuminate\Http\JsonResponse; | ||
use App\Helpers\NotificationHelper; | ||
use App\Http\Controllers\Controller; | ||
use App\Http\ViewHelpers\Project\ProjectViewHelper; | ||
use App\Services\Company\Project\CreateProjectTaskList; | ||
use App\Services\Company\Project\UpdateProjectTaskList; | ||
use App\Http\ViewHelpers\Project\ProjectTasksViewHelper; | ||
use App\Services\Company\Project\DestroyProjectTaskList; | ||
use Illuminate\Database\Eloquent\ModelNotFoundException; | ||
|
||
class ProjectTaskListsController extends Controller | ||
{ | ||
/** | ||
* Display the Create task list view. | ||
* | ||
* @param Request $request | ||
* @param int $companyId | ||
* @param int $projectId | ||
* | ||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|Response | ||
*/ | ||
public function create(Request $request, int $companyId, int $projectId) | ||
{ | ||
$company = InstanceHelper::getLoggedCompany(); | ||
|
||
try { | ||
$project = Project::where('company_id', $company->id) | ||
->with('employees') | ||
->findOrFail($projectId); | ||
} catch (ModelNotFoundException $e) { | ||
return redirect('home'); | ||
} | ||
|
||
return Inertia::render('Project/Messages/Create', [ | ||
'project' => ProjectViewHelper::info($project), | ||
'notifications' => NotificationHelper::getNotifications(InstanceHelper::getLoggedEmployee()), | ||
]); | ||
} | ||
|
||
/** | ||
* Create the task list. | ||
* | ||
* @param Request $request | ||
* @param int $companyId | ||
* @param int $projectId | ||
* @return JsonResponse | ||
*/ | ||
public function store(Request $request, int $companyId, int $projectId): JsonResponse | ||
{ | ||
$loggedEmployee = InstanceHelper::getLoggedEmployee(); | ||
$company = InstanceHelper::getLoggedCompany(); | ||
|
||
$data = [ | ||
'company_id' => $company->id, | ||
'author_id' => $loggedEmployee->id, | ||
'project_id' => $projectId, | ||
'title' => $request->input('title'), | ||
'description' => $request->input('description'), | ||
]; | ||
|
||
$taskList = (new CreateProjectTaskList)->execute($data); | ||
|
||
return response()->json([ | ||
'data' => ProjectTasksViewHelper::getTaskListInfo($taskList), | ||
], 201); | ||
} | ||
|
||
/** | ||
* Update the task list. | ||
* | ||
* @param Request $request | ||
* @param int $companyId | ||
* @param int $projectId | ||
* @param int $projectTaskListId | ||
* @return JsonResponse | ||
*/ | ||
public function update(Request $request, int $companyId, int $projectId, int $projectTaskListId): JsonResponse | ||
{ | ||
$loggedEmployee = InstanceHelper::getLoggedEmployee(); | ||
$company = InstanceHelper::getLoggedCompany(); | ||
|
||
$data = [ | ||
'company_id' => $company->id, | ||
'author_id' => $loggedEmployee->id, | ||
'project_id' => $projectId, | ||
'project_task_list_id' => $projectTaskListId, | ||
'title' => $request->input('title'), | ||
'description' => $request->input('description'), | ||
]; | ||
|
||
$taskList = (new UpdateProjectTaskList)->execute($data); | ||
|
||
return response()->json([ | ||
'data' => ProjectTasksViewHelper::getTaskListInfo($taskList), | ||
], 200); | ||
} | ||
|
||
/** | ||
* Delete the task list. | ||
* | ||
* @param Request $request | ||
* @param int $companyId | ||
* @param int $projectId | ||
* @param int $projectTaskListId | ||
* @return JsonResponse | ||
*/ | ||
public function destroy(Request $request, int $companyId, int $projectId, int $projectTaskListId): JsonResponse | ||
{ | ||
$loggedEmployee = InstanceHelper::getLoggedEmployee(); | ||
$company = InstanceHelper::getLoggedCompany(); | ||
|
||
$data = [ | ||
'company_id' => $company->id, | ||
'author_id' => $loggedEmployee->id, | ||
'project_id' => $projectId, | ||
'project_task_list_id' => $projectTaskListId, | ||
]; | ||
|
||
(new DestroyProjectTaskList)->execute($data); | ||
|
||
return response()->json([ | ||
'data' => true, | ||
], 200); | ||
} | ||
} |
Oops, something went wrong.