feat: implement admin CRUD and toggle functionality for municipalities.
This commit is contained in:
41
resources/views/admin/municipalities/create.blade.php
Normal file
41
resources/views/admin/municipalities/create.blade.php
Normal file
@@ -0,0 +1,41 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>Ajouter une Commune</h2>
|
||||
<a href="{{ route('admin.municipalities.index') }}" class="btn btn-secondary">Retour</a>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('admin.municipalities.store') }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Nom de la Commune</label>
|
||||
<input type="text" class="form-control @error('name') is-invalid @enderror" id="name" name="name" value="{{ old('name') }}" required>
|
||||
@error('name')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="zip_code" class="form-label">Code Postal</label>
|
||||
<input type="text" class="form-control @error('zip_code') is-invalid @enderror" id="zip_code" name="zip_code" value="{{ old('zip_code') }}" required>
|
||||
@error('zip_code')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" class="form-check-input" id="is_active" name="is_active" {{ old('is_active', true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="is_active">Actif</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Enregistrer</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
42
resources/views/admin/municipalities/edit.blade.php
Normal file
42
resources/views/admin/municipalities/edit.blade.php
Normal file
@@ -0,0 +1,42 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>Modifier la Commune: {{ $municipality->name }}</h2>
|
||||
<a href="{{ route('admin.municipalities.index') }}" class="btn btn-secondary">Retour</a>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('admin.municipalities.update', $municipality) }}" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Nom de la Commune</label>
|
||||
<input type="text" class="form-control @error('name') is-invalid @enderror" id="name" name="name" value="{{ old('name', $municipality->name) }}" required>
|
||||
@error('name')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="zip_code" class="form-label">Code Postal</label>
|
||||
<input type="text" class="form-control @error('zip_code') is-invalid @enderror" id="zip_code" name="zip_code" value="{{ old('zip_code', $municipality->zip_code) }}" required>
|
||||
@error('zip_code')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" class="form-check-input" id="is_active" name="is_active" {{ old('is_active', $municipality->is_active) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="is_active">Actif</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Mettre à jour</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h2 class="mb-4">Gestion des Communes</h2>
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>Gestion des Communes</h2>
|
||||
<a href="{{ route('admin.municipalities.create') }}" class="btn btn-primary">Ajouter une Commune</a>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
@@ -29,12 +32,22 @@
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<form action="{{ route('admin.municipalities.toggle', $municipality) }}" method="POST">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-sm {{ $municipality->is_active ? 'btn-outline-danger' : 'btn-outline-success' }}">
|
||||
{{ $municipality->is_active ? 'Désactiver' : 'Activer' }}
|
||||
</button>
|
||||
</form>
|
||||
<div class="d-flex gap-2">
|
||||
<a href="{{ route('admin.municipalities.edit', $municipality) }}" class="btn btn-sm btn-outline-primary">Modifier</a>
|
||||
|
||||
<form action="{{ route('admin.municipalities.toggle', $municipality) }}" method="POST">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-sm {{ $municipality->is_active ? 'btn-outline-secondary' : 'btn-outline-success' }}">
|
||||
{{ $municipality->is_active ? 'Désactiver' : 'Activer' }}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form action="{{ route('admin.municipalities.destroy', $municipality) }}" method="POST" onsubmit="return confirm('Êtes-vous sûr de vouloir supprimer cette commune ?');">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">Supprimer</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
Reference in New Issue
Block a user