EmployeeController.php done

This commit is contained in:
ASTIER Yann 2024-11-28 14:30:11 +01:00
parent de2ab661b5
commit 5219334da2
8 changed files with 11 additions and 18 deletions

View File

@ -26,8 +26,7 @@ security:
# Easy way to control access for large sections of your site # Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used # Note: Only the *first* access control that matches will be used
access_control: access_control:
# - { path: ^/admin, roles: ROLE_ADMIN } #- { path: ^/*, roles: ROLE_USER }
# - { path: ^/profile, roles: ROLE_USER }
when@test: when@test:
security: security:

View File

@ -14,7 +14,7 @@ use Symfony\Component\Routing\Attribute\Route;
#[Route('/employee', name: 'employee')] #[Route('/employee', name: 'employee')]
final class EmployeeController extends AbstractController final class EmployeeController extends AbstractController
{ {
#[Route(name: '_index', methods: ['GET'])] #[Route('',name: '_index', methods: ['GET'])]
public function index(EmployeeRepository $employeeRepository): Response public function index(EmployeeRepository $employeeRepository): Response
{ {
return $this->render('employee/index.html.twig', [ return $this->render('employee/index.html.twig', [

View File

@ -30,7 +30,7 @@ class EmployeeType extends AbstractType
'multiple' => true, // Allow multiple selections 'multiple' => true, // Allow multiple selections
'expanded' => true, // Render as checkboxes 'expanded' => true, // Render as checkboxes
]) ])
->add('save', SubmitType::class, ['label' => 'Add Employee']); ;
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void

View File

@ -1,4 +1,4 @@
<form method="post" action="{{ path('app_employee_delete', {'id': employee.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');"> <form method="post" action="{{ path('employee_delete', {'id': employee.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ employee.id) }}"> <input type="hidden" name="_token" value="{{ csrf_token('delete' ~ employee.id) }}">
<button class="btn">Delete</button> <button class="btn">Delete</button>
</form> </form>

View File

@ -7,7 +7,7 @@
{{ include('employee/_form.html.twig', {'button_label': 'Update'}) }} {{ include('employee/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_employee_index') }}">back to list</a> <a href="{{ path('employee_index') }}">back to list</a>
{{ include('employee/_delete_form.html.twig') }} {{ include('employee/_delete_form.html.twig') }}
{% endblock %} {% endblock %}

View File

@ -12,7 +12,6 @@
<th>Email</th> <th>Email</th>
<th>FirstName</th> <th>FirstName</th>
<th>LastName</th> <th>LastName</th>
<th>Password</th>
<th>Roles</th> <th>Roles</th>
<th>actions</th> <th>actions</th>
</tr> </tr>
@ -24,11 +23,10 @@
<td>{{ employee.email }}</td> <td>{{ employee.email }}</td>
<td>{{ employee.firstName }}</td> <td>{{ employee.firstName }}</td>
<td>{{ employee.lastName }}</td> <td>{{ employee.lastName }}</td>
<td>{{ employee.password }}</td>
<td>{{ employee.roles ? employee.roles|json_encode : '' }}</td> <td>{{ employee.roles ? employee.roles|json_encode : '' }}</td>
<td> <td>
<a href="{{ path('app_employee_show', {'id': employee.id}) }}">show</a> <a href="{{ path('employee_show', {'id': employee.id}) }}">show</a>
<a href="{{ path('app_employee_edit', {'id': employee.id}) }}">edit</a> <a href="{{ path('employee_edit', {'id': employee.id}) }}">edit</a>
</td> </td>
</tr> </tr>
{% else %} {% else %}
@ -39,5 +37,5 @@
</tbody> </tbody>
</table> </table>
<a href="{{ path('app_employee_new') }}">Create new</a> <a href="{{ path('employee_new') }}">Create new</a>
{% endblock %} {% endblock %}

View File

@ -7,5 +7,5 @@
{{ include('employee/_form.html.twig') }} {{ include('employee/_form.html.twig') }}
<a href="{{ path('app_employee_index') }}">back to list</a> <a href="{{ path('employee_index') }}">back to list</a>
{% endblock %} {% endblock %}

View File

@ -23,10 +23,6 @@
<th>LastName</th> <th>LastName</th>
<td>{{ employee.lastName }}</td> <td>{{ employee.lastName }}</td>
</tr> </tr>
<tr>
<th>Password</th>
<td>{{ employee.password }}</td>
</tr>
<tr> <tr>
<th>Roles</th> <th>Roles</th>
<td>{{ employee.roles ? employee.roles|json_encode : '' }}</td> <td>{{ employee.roles ? employee.roles|json_encode : '' }}</td>
@ -34,9 +30,9 @@
</tbody> </tbody>
</table> </table>
<a href="{{ path('app_employee_index') }}">back to list</a> <a href="{{ path('employee_index') }}">back to list</a>
<a href="{{ path('app_employee_edit', {'id': employee.id}) }}">edit</a> <a href="{{ path('employee_edit', {'id': employee.id}) }}">edit</a>
{{ include('employee/_delete_form.html.twig') }} {{ include('employee/_delete_form.html.twig') }}
{% endblock %} {% endblock %}