From 41ded8ef5deba53658a3aa89f9183a98a1999c65 Mon Sep 17 00:00:00 2001 From: Krzysztof Strzelecki Date: Thu, 3 Oct 2019 13:08:49 +0200 Subject: [PATCH] tworzenie jednostki - zapisywanie nazwy wybranej gminy/powiatu/woj. zamiast ID --- app/Http/Controllers/fireStationController.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/fireStationController.php b/app/Http/Controllers/fireStationController.php index 4f9de4d..a97e451 100644 --- a/app/Http/Controllers/fireStationController.php +++ b/app/Http/Controllers/fireStationController.php @@ -51,12 +51,17 @@ class fireStationController extends Controller $request = request(); + + $voivodeship = DB::table('wojewodztwa')->select('name')->where('id', $request -> voivodeship)->first(); + $county = DB::table('powiaty')->select('name')->where('id', $request -> county)->first(); + $community = DB::table('gminy')->select('name')->where('id', $request -> community)->first(); + $jednostka = fireStation::create([ 'name' => $request -> unitName, 'number' => $request -> number, - 'voivodeship' => $request -> voivodeship, - 'county' => $request -> county, - 'community' => $request -> community, + 'voivodeship' => $voivodeship -> name, + 'county' => $county -> name, + 'community' => $community -> name, 'postOffice' => $request -> postOffice, 'zipCode' => $request -> zipCode, 'address' => $request -> address,