diff --git a/app/Http/Controllers/fireStationController.php b/app/Http/Controllers/fireStationController.php index 1338a78..86f52cf 100644 --- a/app/Http/Controllers/fireStationController.php +++ b/app/Http/Controllers/fireStationController.php @@ -20,23 +20,37 @@ class fireStationController extends Controller public function store() { $this->validate(request(),[ - 'name' => 'required|min:3|max:45', + 'unitName' => 'required|min:3|max:45', 'number' => 'required|numeric', + 'voivodeship' => 'required', + 'county' => 'required', + 'community' => 'required', 'postOffice' => 'required|min:3|max:45', 'zipCode' => 'required|digits:5', + 'latitude' => ['required', 'regex:/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?)$/'], + 'longitude' => ['required', 'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/'], 'address' => 'required|min:3|max:45', 'KRS' => 'required|digits:10', 'NIP' => 'required|digits:10', - 'phoneNumber' => 'required|numeric|min:9|max:11', + 'phoneNumber' => 'required|digits:9', 'email' => 'required|email|unique:firestations', - - + ], + [ + 'required' => ':attribute jest wymagany(e).', + 'min' => ':attribute musi mieć przynajmniej :min znaki.', + 'max' => ':attribute musi mieć nie więcej niż :max znaków.', + 'numeric' => ':attribute może zawierać tylko cyfry.', + 'digits' => ':attribute musi składać się z :digits cyfr.', + 'unique' =>':attribute jest już zajęty.', + 'email' => 'Niepoprawny adres e-mail.', + 'latitude.regex' =>':attribute ma zakres od -90.0 do 90.0', + 'longitude.regex' =>':attribute ma zakres od -180.0 do 180.0' ]); $request = request(); $jednostka = fireStation::create([ - 'name' => $request -> name, + 'name' => $request -> unitName, 'number' => $request -> number, 'voivodeship' => $request -> voivodeship, 'county' => $request -> county, diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 80713bf..2369461 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -151,6 +151,16 @@ return [ 'password' => 'hasło', 'PESEL' => 'numer PESEL', 'phoneNumber' => 'numer telefonu', + 'number' => 'numer jednostki', + 'zipCode' => 'kod pocztowy', + 'postOffice' => 'urząd pocztowy', + 'address' => 'adres', + 'voivodeship' => 'województwo', + 'county' => 'powiat', + 'community' => 'gmina', + 'unitName' => 'nazwa jednostki', + 'longitude' => 'długość geograficzna', + 'latitude' => 'szerokość geograficzna', ], diff --git a/resources/views/inc/addFireStation.blade.php b/resources/views/inc/addFireStation.blade.php index de6ace7..ce73335 100644 --- a/resources/views/inc/addFireStation.blade.php +++ b/resources/views/inc/addFireStation.blade.php @@ -16,7 +16,7 @@ {{ csrf_field() }}