Compare commits
2 Commits
ffcdd46003
...
be1bd0541c
Author | SHA1 | Date | |
---|---|---|---|
be1bd0541c | |||
5cde70a7b3 |
@ -17,4 +17,42 @@ class AffectationController extends AbstractController
|
|||||||
'controller_name' => 'AffectationController',
|
'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 %}
|
@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
<th>Label</th>
|
<th>Label</th>
|
||||||
<th>actions</th>
|
<th>actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for category in categories %}
|
{% for category in categories %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user