diff --git a/app/Http/Controllers/RegistrationController.php b/app/Http/Controllers/RegistrationController.php index d892483..1446e00 100644 --- a/app/Http/Controllers/RegistrationController.php +++ b/app/Http/Controllers/RegistrationController.php @@ -6,54 +6,6 @@ use Illuminate\Http\Request; use App\User; use App\Rules\Pesel; - -/* -class RegistrationController extends Controller -{ - // - public function create() - { - return view('register'); - } - public function store() - { - $this->validate(request(), [ - 'userEmail' => 'required|email', - 'userLogin' => 'required', - 'userPassword' => 'required', - 'userName' => 'required', - 'userLastName' => 'required', - 'userPesel' => 'required', - 'userPhone' => 'required', - - - ]); - - $request = request(); - - #$Uzytkownik = Uzytkownik::create(request(['userLogin', 'userPassword', 'userEmail'])); - $Uzytkownik = Uzytkownik::create([ - 'login' => $request-> userLogin, - 'password' => $request-> userPassword, - 'email' => $request-> userEmail, - 'name' => $request-> userName, - 'surname' => $request-> userLastName, - 'PESEL' => $request-> userPesel, - 'phoneNumber' => $request-> userPhone, - 'email' => $request-> userEmail, - 'functionID' => 1, - 'degreeID' => 1, - 'number' => 'ABC123' - - ]); - - auth()->login($Uzytkownik); - - return redirect()->to('/jednostka'); - } -} - -*/ /* 'phoneNumber' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:9' */ class RegistrationController extends Controller { diff --git a/app/Http/Controllers/fireStationController.php b/app/Http/Controllers/fireStationController.php new file mode 100644 index 0000000..646de38 --- /dev/null +++ b/app/Http/Controllers/fireStationController.php @@ -0,0 +1,45 @@ +validate(request(),[ + + ]); + + + $request = request(); + $jednostka = fireStation::create([ + 'name' => $request -> name, + 'number' => $request -> number, + 'voivodeship' => $request -> voivodeship, + 'county' => $request -> county, + 'community' => $request -> community, + 'postOffice' => $request -> postOffice, + 'zipCode' => $request -> zipCode, + 'address' => $request -> address, + 'latitude' => $request -> latitude, + 'longitude' => $request -> longitude, + 'KRS' => $request -> KRS, + 'NIP' => $request -> NIP, + 'phoneNumber' => $request -> phoneNumber, + 'email' => $request -> email, + 'creatorID' => auth()->user()->id, + 'changingID' => auth()->user()->id + ]); + + $user = auth()->user(); + $user->fireStationID = $jednostka->id; + $user->save(); + + return redirect()->to('/jednostka'); + } +} diff --git a/app/fireStation.php b/app/fireStation.php index aaf3ffa..8e3d4c7 100644 --- a/app/fireStation.php +++ b/app/fireStation.php @@ -7,8 +7,9 @@ use Illuminate\Database\Eloquent\Model; class fireStation extends Model { protected $primaryKey = 'id'; + protected $table = 'fireStations'; protected $fillable = [ - 'name', 'number', 'voivodeship', 'county', 'community', 'postOffice', 'zipCode', 'address', 'latitude', 'longtitude', 'KRS', 'NIP', 'phoneNumber', 'email', 'deleted', 'creatorID', 'changingID', 'remember_token', 'created_at', 'updated_at' + 'name', 'number', 'voivodeship', 'county', 'community', 'postOffice', 'zipCode', 'address', 'latitude', 'longitude', 'KRS', 'NIP', 'phoneNumber', 'email', 'deleted', 'creatorID', 'changingID', 'remember_token', 'created_at', 'updated_at' ]; } diff --git a/resources/views/inc/addFireStation.blade.php b/resources/views/inc/addFireStation.blade.php index b26a803..b91e622 100644 --- a/resources/views/inc/addFireStation.blade.php +++ b/resources/views/inc/addFireStation.blade.php @@ -3,7 +3,7 @@ @section('center-area') @parent