|
@@ -217,7 +217,11 @@ class ProjectController extends Controller
|
|
|
*/
|
|
|
public function destroy(string $id)
|
|
|
{
|
|
|
- $project = Project::allowed($id)->findOrFail($id);
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($id,$isAction)->find($id);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
|
|
|
$project->delete();
|
|
|
|
|
@@ -228,7 +232,11 @@ class ProjectController extends Controller
|
|
|
|
|
|
public function closed(Request $request, string $id)
|
|
|
{
|
|
|
- $project = Project::allowed($id)->findOrFail($id);
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($id,$isAction)->find($id);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
|
|
|
$project->status = ProjectStatus::CLOSED->value;
|
|
|
$changes = ModelChangeDetector::detector(ActionObjectType::PROJECT, $project);
|
|
@@ -245,7 +253,11 @@ class ProjectController extends Controller
|
|
|
|
|
|
public function start(Request $request, string $id)
|
|
|
{
|
|
|
- $project = Project::allowed($id)->findOrFail($id);
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($id,$isAction)->find($id);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
|
|
|
$project->status = ProjectStatus::DOING->value;
|
|
|
$changes = ModelChangeDetector::detector(ActionObjectType::PROJECT, $project);
|
|
@@ -263,7 +275,11 @@ class ProjectController extends Controller
|
|
|
|
|
|
public function pause(Request $request, string $id)
|
|
|
{
|
|
|
- $project = Project::allowed($id)->findOrFail($id);
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($id,$isAction)->find($id);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
|
|
|
$project->status = ProjectStatus::PAUSE->value;
|
|
|
$changes = ModelChangeDetector::detector(ActionObjectType::PROJECT, $project);
|
|
@@ -287,7 +303,11 @@ class ProjectController extends Controller
|
|
|
*/
|
|
|
public function postpone(PostponeRequest $request, string $id)
|
|
|
{
|
|
|
- $project = Project::allowed($id)->findOrFail($id);
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($id,$isAction)->find($id);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
|
|
|
$project->fill($request->only([
|
|
|
'begin', 'end'
|
|
@@ -306,10 +326,12 @@ class ProjectController extends Controller
|
|
|
|
|
|
public function linkRequirement(LinkRequirementRequest $request, string $id)
|
|
|
{
|
|
|
-
|
|
|
$requirementIds = $request->get("requirement_id",[]);
|
|
|
- $project = Project::allowed($id)->findOrFail($id);
|
|
|
-
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($id,$isAction)->find($id);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
|
|
|
if(! $requirementIds){
|
|
|
return $this->forbidden("Please select the correct requirement");
|
|
@@ -344,7 +366,11 @@ class ProjectController extends Controller
|
|
|
{
|
|
|
|
|
|
$requirementIds = $request->get("requirement_id",[]);
|
|
|
- $project = Project::allowed($id)->findOrFail($id);
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($id,$isAction)->find($id);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
|
|
|
if (! $requirementIds) {
|
|
|
return $this->forbidden("Please select the correct requirement");
|
|
@@ -368,7 +394,12 @@ class ProjectController extends Controller
|
|
|
|
|
|
public function linkRequirementByPlan(LinkRequirementByPlanRequest $request, string $id)
|
|
|
{
|
|
|
- $project = Project::allowed($id)->findOrFail($id);
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($id,$isAction)->find($id);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
+
|
|
|
|
|
|
$plan = Plan::findOrFail($request->plan_id);
|
|
|
|
|
@@ -420,7 +451,12 @@ class ProjectController extends Controller
|
|
|
|
|
|
public function notLinkAssetRequirement(string $id)
|
|
|
{
|
|
|
- $project = Project::allowed($id)->findOrFail($id);
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($id,$isAction)->find($id);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
+
|
|
|
$requirements = $project->assets
|
|
|
? Requirement::query()->whereIn('asset_id', $project->assets?->pluck('id')->toArray())->whereNotIn('id', $project->requirements?->pluck('id')->toArray())->simplePaginate()
|
|
|
: [];
|
|
@@ -430,10 +466,12 @@ class ProjectController extends Controller
|
|
|
|
|
|
public function updateLinkAssets(UpdateLinkAssetsRequest $request, string $projectId)
|
|
|
{
|
|
|
- $project = Project::allowed($projectId)->find($projectId);
|
|
|
- if (is_null($project)){
|
|
|
- return $this->badRequest('project does not exist');
|
|
|
- }
|
|
|
+ $isAction=true;
|
|
|
+ $project = Project::allowed($projectId,$isAction)->find($projectId);
|
|
|
+ if($project==null){
|
|
|
+ return $this->badRequest('Permission denied or project not found. Please contact the administrator.');
|
|
|
+ };
|
|
|
+
|
|
|
$assetsIds = $request->assets;
|
|
|
DB::transaction(function () use ($projectId,$assetsIds) {
|
|
|
ProjectAsset::where('project_id', $projectId)->delete();
|