Compare commits
2 Commits
ffcdd46003
...
be1bd0541c
Author | SHA1 | Date | |
---|---|---|---|
be1bd0541c | |||
5cde70a7b3 |
@ -17,4 +17,42 @@ class AffectationController extends AbstractController
|
||||
'controller_name' => 'AffectationController',
|
||||
]);
|
||||
}
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$affectation = Affectation::create($validated);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Affectation réussie',
|
||||
'data' => $affectation
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
$affectations = Affectation::all();
|
||||
|
||||
return response()->json([
|
||||
'data' => $affectations
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$affectation = Affectation::find($id);
|
||||
|
||||
if (!$affectation) {
|
||||
return response()->json(['message' => ''], 404);
|
||||
}
|
||||
|
||||
$affectation->delete();
|
||||
|
||||
return response()->json(['message' => ''], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
21
templates/affectation/index.html.twig
Normal file
21
templates/affectation/index.html.twig
Normal file
@ -0,0 +1,21 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Affectation{% endblock %}
|
||||
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div class="wrapper">
|
||||
<h1>Affectation des utilisateurs.</h1>
|
||||
|
||||
{% for employee in employees %}
|
||||
<tr>
|
||||
<td>{{ employee.id }}</td>
|
||||
</tr>
|
||||
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="7">no records found</td>
|
||||
</tr>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user