create new department Enum to list all french department if the selected country is france
This commit is contained in:
parent
316cdf3e03
commit
103ff22d5b
7 changed files with 393 additions and 75 deletions
354
app/Enums/Department.php
Normal file
354
app/Enums/Department.php
Normal file
|
|
@ -0,0 +1,354 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Kwaadpepper\Enum\BaseEnumRoutable;
|
||||
|
||||
/**
|
||||
* @method static self ain()
|
||||
* @method static self aisne()
|
||||
* @method static self allier()
|
||||
* @method static self alpesDeHauteProvence()
|
||||
* @method static self hautesAlpes()
|
||||
* @method static self alpesMaritimes()
|
||||
* @method static self ardeche()
|
||||
* @method static self ardennes()
|
||||
* @method static self ariege()
|
||||
* @method static self aube()
|
||||
* @method static self aude()
|
||||
* @method static self aveyron()
|
||||
* @method static self bouchesDuRhone()
|
||||
* @method static self calvados()
|
||||
* @method static self cantal()
|
||||
* @method static self charenteeme()
|
||||
* @method static self charenteMaritime()
|
||||
* @method static self cher()
|
||||
* @method static self correze()
|
||||
* @method static self corseDuSud()
|
||||
* @method static self hauteCorse()
|
||||
* @method static self coteDor()
|
||||
* @method static self cotesDarmor()
|
||||
* @method static self creuse()
|
||||
* @method static self dordogne()
|
||||
* @method static self doubs()
|
||||
* @method static self drome()
|
||||
* @method static self eure()
|
||||
* @method static self eureEtLoir()
|
||||
* @method static self finistere()
|
||||
* @method static self gard()
|
||||
* @method static self hauteGaronne()
|
||||
* @method static self gers()
|
||||
* @method static self gironde()
|
||||
* @method static self herault()
|
||||
* @method static self illeEtVilaine()
|
||||
* @method static self indre()
|
||||
* @method static self indreEtLoire()
|
||||
* @method static self isere()
|
||||
* @method static self jura()
|
||||
* @method static self landes()
|
||||
* @method static self loirEtCher()
|
||||
* @method static self loire()
|
||||
* @method static self hauteLoire()
|
||||
* @method static self loireAtlantique()
|
||||
* @method static self loiret()
|
||||
* @method static self lot()
|
||||
* @method static self lotEtGaronne()
|
||||
* @method static self lozere()
|
||||
* @method static self maineEtLoire()
|
||||
* @method static self manche()
|
||||
* @method static self marne()
|
||||
* @method static self hauteMarne()
|
||||
* @method static self mayenne()
|
||||
* @method static self meurtheEtMoselle()
|
||||
* @method static self meuse()
|
||||
* @method static self morbihan()
|
||||
* @method static self moselle()
|
||||
* @method static self nievre()
|
||||
* @method static self nord()
|
||||
* @method static self oise()
|
||||
* @method static self orne()
|
||||
* @method static self pasDeCalais()
|
||||
* @method static self puyDeDome()
|
||||
* @method static self pyreneesAtlantiques()
|
||||
* @method static self hautesPyrenees()
|
||||
* @method static self pyreneesOrientales()
|
||||
* @method static self basRhin()
|
||||
* @method static self hautRhin()
|
||||
* @method static self rhone()
|
||||
* @method static self hauteSaone()
|
||||
* @method static self saoneEtLoire()
|
||||
* @method static self sarthe()
|
||||
* @method static self savoie()
|
||||
* @method static self hauteSavoie()
|
||||
* @method static self paris()
|
||||
* @method static self seineMaritime()
|
||||
* @method static self seineEtMarne()
|
||||
* @method static self yvelines()
|
||||
* @method static self deuxSevres()
|
||||
* @method static self somme()
|
||||
* @method static self tarn()
|
||||
* @method static self tarnEtGaronne()
|
||||
* @method static self var()
|
||||
* @method static self vaucluse()
|
||||
* @method static self vendee()
|
||||
* @method static self vienne()
|
||||
* @method static self hauteVienne()
|
||||
* @method static self vosges()
|
||||
* @method static self yonne()
|
||||
* @method static self territoireDeBelfort()
|
||||
* @method static self essonne()
|
||||
* @method static self hautsDeSeine()
|
||||
* @method static self seineSaintDenis()
|
||||
* @method static self valDeMarne()
|
||||
* @method static self valDoise()
|
||||
* @method static self guadeloupe()
|
||||
* @method static self martinique()
|
||||
* @method static self guyane()
|
||||
* @method static self laReunion()
|
||||
* @method static self saintPierreEtMiquelon()
|
||||
* @method static self mayotte()
|
||||
* @method static self saintBarthelemy()
|
||||
* @method static self saintMartin()
|
||||
* @method static self wallisEtFutuna()
|
||||
* @method static self polynesieFrancaise()
|
||||
* @method static self nouvelleCaledonie()
|
||||
* @package App\Enums
|
||||
*/
|
||||
class Department extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
'ain' => 1,
|
||||
'aisne' => 2,
|
||||
'allier' => 3,
|
||||
'alpesDeHauteProvence' => 4,
|
||||
'hautesAlpes' => 5,
|
||||
'alpesMaritimes' => 6,
|
||||
'ardeche' => 7,
|
||||
'ardennes' => 8,
|
||||
'ariege' => 9,
|
||||
'aube' => 10,
|
||||
'aude' => 11,
|
||||
'aveyron' => 12,
|
||||
'bouchesDuRhone' => 13,
|
||||
'calvados' => 14,
|
||||
'cantal' => 15,
|
||||
'charenteeme' => 16,
|
||||
'charenteMaritime' => 17,
|
||||
'cher' => 18,
|
||||
'correze' => 19,
|
||||
'corseDuSud' => '2A',
|
||||
'hauteCorse' => '2B',
|
||||
'coteDor' => 21,
|
||||
'cotesDarmor' => 22,
|
||||
'creuse' => 23,
|
||||
'dordogne' => 24,
|
||||
'doubs' => 25,
|
||||
'drome' => 26,
|
||||
'eure' => 27,
|
||||
'eureEtLoir' => 28,
|
||||
'finistere' => 29,
|
||||
'gard' => 30,
|
||||
'hauteGaronne' => 31,
|
||||
'gers' => 32,
|
||||
'gironde' => 33,
|
||||
'herault' => 34,
|
||||
'illeEtVilaine' => 35,
|
||||
'indre' => 36,
|
||||
'indreEtLoire' => 37,
|
||||
'isere' => 38,
|
||||
'jura' => 39,
|
||||
'landes' => 40,
|
||||
'loirEtCher' => 41,
|
||||
'loire' => 42,
|
||||
'hauteLoire' => 43,
|
||||
'loireAtlantique' => 44,
|
||||
'loiret' => 45,
|
||||
'lot' => 46,
|
||||
'lotEtGaronne' => 47,
|
||||
'lozere' => 48,
|
||||
'maineEtLoire' => 49,
|
||||
'manche' => 50,
|
||||
'marne' => 51,
|
||||
'hauteMarne' => 52,
|
||||
'mayenne' => 53,
|
||||
'meurtheEtMoselle' => 54,
|
||||
'meuse' => 55,
|
||||
'morbihan' => 56,
|
||||
'moselle' => 57,
|
||||
'nievre' => 58,
|
||||
'nord' => 59,
|
||||
'oise' => 60,
|
||||
'orne' => 61,
|
||||
'pasDeCalais' => 62,
|
||||
'puyDeDome' => 63,
|
||||
'pyreneesAtlantiques' => 64,
|
||||
'hautesPyrenees' => 65,
|
||||
'pyreneesOrientales' => 66,
|
||||
'basRhin' => 67,
|
||||
'hautRhin' => 68,
|
||||
'rhone' => 69,
|
||||
'hauteSaone' => 70,
|
||||
'saoneEtLoire' => 71,
|
||||
'sarthe' => 72,
|
||||
'savoie' => 73,
|
||||
'hauteSavoie' => 74,
|
||||
'paris' => 75,
|
||||
'seineMaritime' => 76,
|
||||
'seineEtMarne' => 77,
|
||||
'yvelines' => 78,
|
||||
'deuxSevres' => 79,
|
||||
'somme' => 80,
|
||||
'tarn' => 81,
|
||||
'tarnEtGaronne' => 82,
|
||||
'var' => 83,
|
||||
'vaucluse' => 84,
|
||||
'vendee' => 85,
|
||||
'vienne' => 86,
|
||||
'hauteVienne' => 87,
|
||||
'vosges' => 88,
|
||||
'yonne' => 89,
|
||||
'territoireDeBelfort' => 90,
|
||||
'essonne' => 91,
|
||||
'hautsDeSeine' => 92,
|
||||
'seineSaintDenis' => 93,
|
||||
'valDeMarne' => 94,
|
||||
'valDoise' => 95,
|
||||
'guadeloupe' => 971,
|
||||
'martinique' => 972,
|
||||
'guyane' => 973,
|
||||
'laReunion' => 974,
|
||||
'saintPierreEtMiquelon' => 975,
|
||||
'mayotte' => 976,
|
||||
'saintBarthelemy' => 977,
|
||||
'saintMartin' => 978,
|
||||
'wallisEtFutuna' => 986,
|
||||
'polynesieFrancaise' => 987,
|
||||
'nouvelleCaledonie' => 988
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
'ain' => 'Ain',
|
||||
'aisne' => 'Aisne',
|
||||
'allier' => 'Allier',
|
||||
'alpesDeHauteProvence' => 'Alpes-de-Haute-Provence',
|
||||
'hautesAlpes' => 'Hautes-alpes',
|
||||
'alpesMaritimes' => 'Alpes-maritimes',
|
||||
'ardeche' => 'Ardèche',
|
||||
'ardennes' => 'Ardennes',
|
||||
'ariege' => 'Ariège',
|
||||
'aube' => 'Aube',
|
||||
'aude' => 'Aude',
|
||||
'aveyron' => 'Aveyron',
|
||||
'bouchesDuRhone' => 'Bouches-du-Rhône',
|
||||
'calvados' => 'Calvados',
|
||||
'cantal' => 'Cantal',
|
||||
'charenteeme' => 'Charenteême',
|
||||
'charenteMaritime' => 'Charente-maritime',
|
||||
'cher' => 'Cher',
|
||||
'correze' => 'Corrèze',
|
||||
'corseDuSud' => 'Corse-du-sud',
|
||||
'hauteCorse' => 'Haute-Corse',
|
||||
'coteDor' => 'Côte-d\'Or',
|
||||
'cotesDarmor' => 'Côtes-d\'Armor',
|
||||
'creuse' => 'Creuse',
|
||||
'dordogne' => 'Dordogne',
|
||||
'doubs' => 'Doubs',
|
||||
'drome' => 'Drôme',
|
||||
'eure' => 'Eure',
|
||||
'eureEtLoir' => 'Eure-et-loir',
|
||||
'finistere' => 'Finistère',
|
||||
'gard' => 'Gard',
|
||||
'hauteGaronne' => 'Haute-garonne',
|
||||
'gers' => 'Gers',
|
||||
'gironde' => 'Gironde',
|
||||
'herault' => 'Hérault',
|
||||
'illeEtVilaine' => 'Ille-et-vilaine',
|
||||
'indre' => 'Indre',
|
||||
'indreEtLoire' => 'Indre-et-loire',
|
||||
'isere' => 'Isère',
|
||||
'jura' => 'Jura',
|
||||
'landes' => 'Landes',
|
||||
'loirEtCher' => 'Loir-et-cher',
|
||||
'loire' => 'Loire',
|
||||
'hauteLoire' => 'Haute-loire',
|
||||
'loireAtlantique' => 'Loire-atlantique',
|
||||
'loiret' => 'Loiret',
|
||||
'lot' => 'Lot',
|
||||
'lotEtGaronne' => 'Lot-et-garonne',
|
||||
'lozere' => 'Lozère',
|
||||
'maineEtLoire' => 'Maine-et-loire',
|
||||
'manche' => 'Manche',
|
||||
'marne' => 'Marne',
|
||||
'hauteMarne' => 'Haute-marne',
|
||||
'mayenne' => 'Mayenne',
|
||||
'meurtheEtMoselle' => 'Meurthe-et-moselle',
|
||||
'meuse' => 'Meuse',
|
||||
'morbihan' => 'Morbihan',
|
||||
'moselle' => 'Moselle',
|
||||
'nievre' => 'Nièvre',
|
||||
'nord' => 'Nord',
|
||||
'oise' => 'Oise',
|
||||
'orne' => 'Orne',
|
||||
'pasDeCalais' => 'Pas-de-calais',
|
||||
'puyDeDome' => 'Puy-de-dôme',
|
||||
'pyreneesAtlantiques' => 'Pyrénées-atlantiques',
|
||||
'hautesPyrenees' => 'Hautes-Pyrénées',
|
||||
'pyreneesOrientales' => 'Pyrénées-orientales',
|
||||
'basRhin' => 'Bas-rhin',
|
||||
'hautRhin' => 'Haut-rhin',
|
||||
'rhone' => 'Rhône',
|
||||
'hauteSaone' => 'Haute-saône',
|
||||
'saoneEtLoire' => 'Saône-et-loire',
|
||||
'sarthe' => 'Sarthe',
|
||||
'savoie' => 'Savoie',
|
||||
'hauteSavoie' => 'Haute-savoie',
|
||||
'paris' => 'Paris',
|
||||
'seineMaritime' => 'Seine-maritime',
|
||||
'seineEtMarne' => 'Seine-et-marne',
|
||||
'yvelines' => 'Yvelines',
|
||||
'deuxSevres' => 'Deux-sèvres',
|
||||
'somme' => 'Somme',
|
||||
'tarn' => 'Tarn',
|
||||
'tarnEtGaronne' => 'Tarn-et-Garonne',
|
||||
'var' => 'Var',
|
||||
'vaucluse' => 'Vaucluse',
|
||||
'vendee' => 'Vendée',
|
||||
'vienne' => 'Vienne',
|
||||
'hauteVienne' => 'Haute-vienne',
|
||||
'vosges' => 'Vosges',
|
||||
'yonne' => 'Yonne',
|
||||
'territoireDeBelfort' => 'Territoire de belfort',
|
||||
'essonne' => 'Essonne',
|
||||
'hautsDeSeine' => 'Hauts-de-seine',
|
||||
'seineSaintDenis' => 'Seine-Saint-Denis',
|
||||
'valDeMarne' => 'Val-de-marne',
|
||||
'valDoise' => 'Val-d\'Oise',
|
||||
'guadeloupe' => 'Guadeloupe',
|
||||
'martinique' => 'Martinique',
|
||||
'guyane' => 'Guyane',
|
||||
'laReunion' => 'La réunion',
|
||||
'saintPierreEtMiquelon' => 'Saint-Pierre-et-Miquelon',
|
||||
'mayotte' => 'Mayotte',
|
||||
'saintBarthelemy' => 'Saint-Barthélemy',
|
||||
'saintMartin' => 'Saint-Martin',
|
||||
'wallisEtFutuna' => 'Wallis-et-Futuna',
|
||||
'polynesieFrancaise' => 'Polynésie-française',
|
||||
'nouvelleCaledonie' => 'Nouvelle-Calédonie',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\Country;
|
||||
use App\Enums\Department;
|
||||
use App\Http\Requests\ContactFormRequest;
|
||||
use App\Mail\SendContactMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
|
@ -26,7 +28,14 @@ class ContactController extends Controller
|
|||
*/
|
||||
public function contactSubmit(ContactFormRequest $request)
|
||||
{
|
||||
Mail::to(config('mail.contactsList.contactform'))->send(new SendContactMail($request->validated()));
|
||||
|
||||
$data = \collect($request->validated());
|
||||
$data->put('country', Country::make(intval($request->post('country')))->label);
|
||||
if ($request->post('department')) {
|
||||
$data->put('departement', Department::make(intval($request->post('departement')))->label);
|
||||
}
|
||||
|
||||
Mail::to(config('mail.contactsList.contactform'))->send(new SendContactMail($data->all()));
|
||||
|
||||
$lang = session()->get('lang', config('app.locale'));
|
||||
return redirect()->route(session()->get('lang', config('app.locale')) === 'fr' ? 'contact' : $lang . ".contact")
|
||||
|
|
|
|||
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Enums\Country;
|
||||
use App\Enums\Department;
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
||||
|
||||
class ContactFormRequest extends FormRequest
|
||||
{
|
||||
|
|
@ -35,8 +38,15 @@ class ContactFormRequest extends FormRequest
|
|||
'city' => 'required|string|max:255',
|
||||
'phone' => 'required|numeric|min:1|max:9999999999',
|
||||
'email' => 'required|email:rfc,dns,spoof|max:255',
|
||||
'country' => 'required|string|max:255',
|
||||
'departement' => 'required_if:country,France|max:255',
|
||||
'country' => [
|
||||
'required',
|
||||
new EnumIsValidRule(Country::class)
|
||||
],
|
||||
'departement' => [
|
||||
'required_if:country,' . Country::france()->label,
|
||||
'nullable',
|
||||
new EnumIsValidRule(Department::class)
|
||||
],
|
||||
'topic' => 'required',
|
||||
'product_name' => 'required_if:topic,Réclamation|max:255',
|
||||
'barcode' => 'required_if:topic,Réclamation|max:128',
|
||||
|
|
|
|||
|
|
@ -65,19 +65,6 @@
|
|||
"Doux, La référence française de la volaille": "",
|
||||
"Sélectionnez un pays": "",
|
||||
"Sélectionnez un département": "",
|
||||
"Guadeloupe": "",
|
||||
"Martinique": "",
|
||||
"Guyane": "",
|
||||
"La Réunion": "",
|
||||
"Mayotte": "",
|
||||
"Saint-Pierre-et-Miquelon": "",
|
||||
"Saint-Barthélémy": "",
|
||||
"Saint-Martin": "",
|
||||
"Polynésie française": "",
|
||||
"Île de Clipperton": "",
|
||||
"Wallis-et-Futuna": "",
|
||||
"Nouvelle-Calédonie": "",
|
||||
"Terres australes et antarctiques françaises": "",
|
||||
"Doux Food Services": "",
|
||||
"Tous les produits Doux": "",
|
||||
"Les actualités Doux": "",
|
||||
|
|
@ -85,4 +72,4 @@
|
|||
"<span class=\"color-red\">les questions<\/span><br><span class=\"color-blue\">utiles<\/span>": "<span class=\"color-red\">Usefull<\/span><br><span class=\"color-blue\">questions<\/span>",
|
||||
"Nos nouveautés": "",
|
||||
"Nous travaillons toujours pour améliorer nos recettes et proposer des produits de meilleure qualité": ""
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,19 +65,6 @@
|
|||
"Doux, La référence française de la volaille": "Doux, La referencia francesa de la carne de ave",
|
||||
"Sélectionnez un pays": "Seleccione un país",
|
||||
"Sélectionnez un département": "Seleccione una provincia",
|
||||
"Guadeloupe": "Guadalupe",
|
||||
"Martinique": "Martinica",
|
||||
"Guyane": "Guayana",
|
||||
"La Réunion": "Reunión",
|
||||
"Mayotte": "Mayotte",
|
||||
"Saint-Pierre-et-Miquelon": "San Pedro y Miquelón",
|
||||
"Saint-Barthélémy": "San Bartolomé",
|
||||
"Saint-Martin": "San Martín",
|
||||
"Polynésie française": "Polinesia francesa",
|
||||
"Île de Clipperton": "Isla Clipperton",
|
||||
"Wallis-et-Futuna": "Wallis y Futuna",
|
||||
"Nouvelle-Calédonie": "Nueva Caledonia",
|
||||
"Terres australes et antarctiques françaises": "Territorios australes y antárticos franceses",
|
||||
"Doux Food Services": "Doux Food Services",
|
||||
"Tous les produits Doux": "Todos los productos Doux",
|
||||
"Les actualités Doux": "Las últimas noticias de Doux",
|
||||
|
|
@ -85,4 +72,4 @@
|
|||
"<span class=\"color-red\">les questions<\/span><br><span class=\"color-blue\">utiles<\/span>": "<span class=\"color-red\">Preguntas<\/span><br><span class=\"color-blue\">útiles<\/span>",
|
||||
"Nos nouveautés": "nuestras novedades",
|
||||
"Nous travaillons toujours pour améliorer nos recettes et proposer des produits de meilleure qualité": "Seguimos trabajando para mejorar nuestras recetas y proponer productos de mejor calidad"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,19 +65,6 @@
|
|||
"Doux, La référence française de la volaille": "Doux, La référence française de la volaille",
|
||||
"Sélectionnez un pays": "",
|
||||
"Sélectionnez un département": "",
|
||||
"Guadeloupe": "",
|
||||
"Martinique": "",
|
||||
"Guyane": "",
|
||||
"La Réunion": "",
|
||||
"Mayotte": "",
|
||||
"Saint-Pierre-et-Miquelon": "",
|
||||
"Saint-Barthélémy": "",
|
||||
"Saint-Martin": "",
|
||||
"Polynésie française": "",
|
||||
"Île de Clipperton": "",
|
||||
"Wallis-et-Futuna": "",
|
||||
"Nouvelle-Calédonie": "",
|
||||
"Terres australes et antarctiques françaises": "",
|
||||
"Doux Food Services": "",
|
||||
"Tous les produits Doux": "",
|
||||
"Les actualités Doux": "",
|
||||
|
|
@ -85,4 +72,4 @@
|
|||
"<span class=\"color-red\">les questions<\/span><br><span class=\"color-blue\">utiles<\/span>": "<span class=\"color-red\">les questions<\/span><br><span class=\"color-blue\">utiles<\/span>",
|
||||
"Nos nouveautés": "Produits à la une",
|
||||
"Nous travaillons toujours pour améliorer nos recettes et proposer des produits de meilleure qualité": "Ne ratez aucune de nos nouveautés"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,26 +113,16 @@
|
|||
<select id="country" class="changeLength" maxlength="255" name="country" required>
|
||||
<option value="" @if(!old('country')) selected @endif>{{ __('Sélectionnez un pays') }} *</option>
|
||||
@foreach($availableCountries as $country)
|
||||
<option value="{{ $country->label }}" @if(old('country') == $country->label) selected @endif>{{ $country->label }}</option>
|
||||
<option value="{{ $country->value }}" @if(old('country') == $country->value) selected @endif>{{ __($country->label) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="drom">
|
||||
<select id="departement" class="changeLength" maxlength="255" name="departement">
|
||||
<option value="" @if(!old('departement')) selected @endif>{{ __('Sélectionnez un département') }} *</option>
|
||||
<option value="Guadeloupe" @if(old('departement') === 'Guadeloupe') selected @endif>{{ __('Guadeloupe') }}</option>
|
||||
<option value="Martinique" @if(old('departement') === 'Martinique') selected @endif>{{ __('Martinique') }}</option>
|
||||
<option value="Guyane" @if(old('departement') === 'Guyane') selected @endif>{{ __('Guyane') }}</option>
|
||||
<option value="La Réunion" @if(old('departement') === 'La Réunion') selected @endif>{{ __('La Réunion') }}</option>
|
||||
<option value="Mayotte" @if(old('departement') === 'Mayotte') selected @endif>{{ __('Mayotte') }}</option>
|
||||
<option value="Saint-Pierre-et-Miquelon" @if(old('departement') === 'Saint-Pierre-et-Miquelon') selected @endif>{{ __('Saint-Pierre-et-Miquelon') }}</option>
|
||||
<option value="Saint-Barthélémy" @if(old('departement') === 'Saint-Barthélémy') selected @endif>{{ __('Saint-Barthélémy') }}</option>
|
||||
<option value="Saint-Martin" @if(old('departement') === 'Saint-Martin') selected @endif>{{ __('Saint-Martin') }}</option>
|
||||
<option value="Polynésie française" @if(old('departement') === 'Polynésie française') selected @endif>{{ __('Polynésie française') }}</option>
|
||||
<option value="Île de Clipperton" @if(old('departement') === 'Île de Clipperton') selected @endif>{{ __('Île de Clipperton') }}</option>
|
||||
<option value="Wallis-et-Futuna" @if(old('departement') === 'Wallis-et-Futuna') selected @endif>{{ __('Wallis-et-Futuna') }}</option>
|
||||
<option value="Nouvelle-Calédonie" @if(old('departement') === 'Nouvelle-Calédonie') selected @endif>{{ __('Nouvelle-Calédonie') }}</option>
|
||||
<option value="Terres australes et antarctiques françaises" @if(old('departement') === 'Terres australes et antarctiques françaises') selected @endif>{{ __('Terres australes et antarctiques françaises') }}</option>
|
||||
@foreach (\App\Enums\Department::toArray() as $departement)
|
||||
<option value="{{ $departement->value }}" @if(old('departement') === $departement->value) selected @endif>{{ __($departement->label) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -228,31 +218,25 @@
|
|||
document.getElementById('file').required = false;
|
||||
}
|
||||
|
||||
function showDromField(sel) {
|
||||
if (document.getElementById('country').options[sel.selectedIndex].text=='France') {
|
||||
var dromList = document.getElementById('departement');
|
||||
dromList.style.display = 'initial';
|
||||
dromList.required = true;
|
||||
function showDromField() {
|
||||
const countryList = document.getElementById('country');
|
||||
const departmentList = document.getElementById('departement');
|
||||
if (countryList.value=='{{ \App\Enums\Country::france()->value }}') {
|
||||
departmentList.style.display = 'initial';
|
||||
departmentList.required = true;
|
||||
} else {
|
||||
hideDromField();
|
||||
departmentList.style.display = 'none';
|
||||
departmentList.required = false;
|
||||
}
|
||||
}
|
||||
|
||||
function hideDromField() {
|
||||
var dromList = document.getElementById('departement');
|
||||
dromList.style.display = 'none';
|
||||
dromList.required = false;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
hideReclaFields();
|
||||
hideDromField();
|
||||
showDromField();
|
||||
@if (old('topic')=="Réclamation")
|
||||
showReclaFields();
|
||||
@endif
|
||||
@if (old('country')=="France")
|
||||
showDromField();
|
||||
@endif
|
||||
document.getElementById('country').addEventListener('change', showDromField)
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue