Skip to content

Commit

Permalink
Merge pull request #187 from dbarzin/dev
Browse files Browse the repository at this point in the history
fix api
  • Loading branch information
dbarzin authored Oct 15, 2024
2 parents 1973569 + 355f156 commit 593b9e3
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/Http/Controllers/API/ControlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function store(Request $request)
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden');

$control = Control::create($request->all());
if ($request->has('measures'))
$control->measures()->sync($request->input('measures', []));

return response()->json($control, 201);
}
Expand All @@ -40,6 +42,8 @@ public function update(Request $request, Control $control)
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden');

$control->update($request->all());
if ($request->has('measures'))
$control->measures()->sync($request->input('measures', []));

return response()->json();
}
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/API/MeasureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function store(Request $request)
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden');

$measure = Measure::create($request->all());
if ($request->has('controls'))
$measure->controls()->sync($request->input('controls', []));

return response()->json($measure, 201);
}
Expand All @@ -40,6 +42,8 @@ public function update(Request $request, Measure $measure)
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden');

$measure->update($request->all());
if ($request->has('controls'))
$measure->controls()->sync($request->input('controls', []));

return response()->json();
}
Expand Down
9 changes: 9 additions & 0 deletions app/Models/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ class Control extends Model
];

protected $fillable = [
'name',
'objective',
'observations',
'input',
'attributes',
'model',
'action_plan',
'realisation_date',
'plan_date',
];

// Control status :
Expand Down
3 changes: 3 additions & 0 deletions app/Models/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ class Domain extends Model
];

protected $fillable = [
'title',
'framework',
'description',
];
}
6 changes: 6 additions & 0 deletions app/Models/Measure.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ class Measure extends Model
];

protected $fillable = [
'name',
'clause',
'objective',
'input',
'attributes',
'model',
];

// Return the domain associated to this measure
Expand Down
2 changes: 1 addition & 1 deletion docs/api.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Voici quelques exemples d'utilisation de l'API avec PHP :
$token = json_decode($response)->token;

} else {
error_log($responseInfo['http_code']);
error_log($response);
error_log("No login api status 403");
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Here are a few examples of how to use the API with PHP:
$token = json_decode($response)->token;

} else {
error_log($responseInfo['http_code']);
error_log($response);
error_log("No login api status 403");
}
}
Expand Down

0 comments on commit 593b9e3

Please sign in to comment.