This commit is contained in:
Krzysztof Strzelecki 2019-09-25 18:54:10 +02:00
commit cbb82b014a
5 changed files with 123 additions and 59 deletions

View File

@ -0,0 +1,67 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use App\fireStation;
use App\Rules\Pesel;
class fireFightersController extends Controller
{
public function create(){
return view('fireFighters');
}
public function addForm(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
$fireStation = fireStation::find(auth()->user()->fireStationID);
if($fireStation-> creatorID == auth()->user()->id){
return view('fireFightersAdd');
} else return view("fireFighters");
} else return view("unit");
}
public function store(){
$this->validate(request(), [
'name' => 'required|alpha|min:3|max:45',
'surname' => 'required|alpha|min:3|max:45',
'PESEL' => new Pesel,
'phoneNumber' => 'required|digits:9',
'email' => 'required|email|unique:users',
],
[
'required' => ':attribute jest wymagany(e).',
'min' => ':attribute musi mieć przynajmniej :min znaki.',
'max' => ':attribute musi mieć nie więcej niż :max znaków.',
'alpha' => ':attribute może zawierać tylko litery.',
'alpha_num' => ':attribute może zawierać tylko litery i cyfry.',
'digits' => ':attribute musi składać się z :digits cyfr.',
'unique' =>':attribute jest już zajęty.',
'confirmed' =>':attribute się nie zgadza.',
'email' => 'Niepoprawny adres e-mail.'
]);
$request = request();
$user = User::create([
'password' => '123',
'email' => $request-> email,
'name' => $request-> name,
'surname' => $request-> surname,
'PESEL' => $request-> PESEL,
'phoneNumber' => $request-> phoneNumber,
'functionID' => 1,
'degreeID' => 1,
'number' => 'ABC123',
'fireStationID' => auth()->user()->fireStationID,
'creatorID' => auth()->user()-> id,
'changingID' => auth()->user()-> id
]);
return view('fireFighters');
}
}

View File

@ -3,7 +3,7 @@
@section('left-menu')
@parent
<ul>
<li>Dodaj<img src="img/left_menu_icon/add.png"></li>
<a href="/strazacy/add"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a>
<li>Edytuj<img src="img/left_menu_icon/edit.png"></li>
<li>Wyklucz<img src="img/left_menu_icon/delete.png"></li>
<li>Zawieś<img src="img/left_menu_icon/suspended.png"></li>

View File

@ -0,0 +1,49 @@
@extends('layout.app')
@section('left-menu')
@parent
<ul>
<a href="/strazacy/add"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a>
<li>Edytuj<img src="img/left_menu_icon/edit.png"></li>
<li>Wyklucz<img src="img/left_menu_icon/delete.png"></li>
<li>Zawieś<img src="img/left_menu_icon/suspended.png"></li>
<li>Więcej<img src="img/left_menu_icon/more.png"></li>
</ul>
@stop
@section('center-area')
@parent
<form method="POST" action="/strazacy">
{{ csrf_field() }}
<div class="form-group">
<label for="name">Imię:</label>
<input type="text" class="form-control" id="name" name="name" value="{{ old('name') }} ">
</div>
<div class="form-group">
<label for="name">Nazwisko:</label>
<input type="text" class="form-control" id="surname" name="surname" value="{{ old('surname') }}">
</div>
<div class="form-group">
<label for="name">Pesel:</label>
<input type="text" class="form-control" id="PESEL" name="PESEL" value="{{ old('PESEL') }}">
</div>
<div class="form-group">
<label for="name">Numer telefonu:</label>
<input type="text" class="form-control" id="phoneNumber" name="phoneNumber" value="{{ old('phoneNumber') }}">
</div>
<div class="form-group">
<label for="email">Adres e-mail:</label>
<input type="email" class="form-control" id="email" name="email" value="{{ old('email') }}">
</div>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Submit</button>
</div>
@include('inc.formerrors')
</form>
@stop

View File

@ -3,61 +3,6 @@
@section('center-area')
@parent
{{-- <form action="/register" method="post">--}}
{{-- Użytkownik--}}
{{-- {{ csrf_field() }}--}}
{{-- <div class="form-group">--}}
{{-- <label for="title">Imię</label>--}}
{{-- <input type="text" class="form-control" id="userName" name="userName">--}}
{{-- </div>--}}
{{-- <div class="form-group">--}}
{{-- <label for="title">Nazwisko</label>--}}
{{-- <input type="text" class="form-control" id="userLastName" name="userLastName">--}}
{{-- </div>--}}
{{-- <div class="form-group">--}}
{{-- <label for="title">Pesel</label>--}}
{{-- <input type="text" class="form-control" id="userPesel" name="userPesel">--}}
{{-- </div>--}}
{{-- <div class="form-group">--}}
{{-- <label for="title">Email</label>--}}
{{-- <input type="text" class="form-control" id="userEmail" name="userEmail">--}}
{{-- </div>--}}
{{-- <label for="title">Numer telefonu</label>--}}
{{-- <input type="text" class="form-control" id="userPhone" name="userPhone">--}}
{{-- </div>--}}
{{-- <div class="form-group">--}}
{{-- <label for="title">Login</label>--}}
{{-- <input type="text" class="form-control" id="userLogin" name="userLogin">--}}
{{-- </div>--}}
{{-- <div class="form-group">--}}
{{-- <label for="title">Hasło</label>--}}
{{-- <input type="text" class="form-control" id="userPassword" name="userPassword">--}}
{{-- </div>--}}
{{-- <div class="form-group">--}}
{{-- <label for="title">Powtórz Hasło</label>--}}
{{-- <input type="text" class="form-control" id="userPassword2" name="userPassword2">--}}
{{-- </div>--}}
{{-- @if ($errors->any())--}}
{{-- <div class="alert alert-danger">--}}
{{-- <ul>--}}
{{-- @foreach ($errors->all() as $error)--}}
{{-- <li>{{ $error }}</li>--}}
{{-- @endforeach--}}
{{-- </ul>--}}
{{-- </div>--}}
{{-- @endif--}}
{{-- <button type="submit" class="btn btn-primary">Zarejestruj</button>--}}
{{-- </form>--}}
<h2>Register</h2>
<form method="POST" action="/register">
{{ csrf_field() }}

View File

@ -16,9 +16,6 @@ Route::get('/', function () {
});
Route::get('/strazacy', function (){
return view('firefighters');
});
Route::get('/dokumentacja', function(){
return view('documents');
@ -49,10 +46,16 @@ Route::get('/logout', 'SessionsController@destroy');
Route::get('/jednostka', 'fireStationController@create');
Route::post('/jednostka', 'fireStationController@store');
Route::get('/strazacy', 'fireFightersController@create');
Route::get('/strazacy/add', 'fireFightersController@addForm');
Route::post('/strazacy', 'fireFightersController@store');
Route::get('/jednostka','DataController@getVoivodeships');
Route::get('/jednostka/getcounties/{id}','DataController@getCounties');
Route::get('/jednostka/getcommunities/{id}','DataController@getCommunities');
//Auth::routes();
//
//Route::get('/home', 'HomeController@index')->name('home');