forked from s421507/eOSP2
Dodawanie uzytkownikow do jednostki
This commit is contained in:
parent
3e168bc3a5
commit
9135b7d442
67
app/Http/Controllers/fireFightersController.php
Normal file
67
app/Http/Controllers/fireFightersController.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
@section('left-menu')
|
@section('left-menu')
|
||||||
@parent
|
@parent
|
||||||
<ul>
|
<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>Edytuj<img src="img/left_menu_icon/edit.png"></li>
|
||||||
<li>Wyklucz<img src="img/left_menu_icon/delete.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>Zawieś<img src="img/left_menu_icon/suspended.png"></li>
|
49
resources/views/fireFightersAdd.blade.php
Normal file
49
resources/views/fireFightersAdd.blade.php
Normal 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
|
@ -3,61 +3,6 @@
|
|||||||
|
|
||||||
@section('center-area')
|
@section('center-area')
|
||||||
@parent
|
@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>
|
<h2>Register</h2>
|
||||||
<form method="POST" action="/register">
|
<form method="POST" action="/register">
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
|
@ -16,9 +16,6 @@ Route::get('/', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Route::get('/strazacy', function (){
|
|
||||||
return view('firefighters');
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::get('/dokumentacja', function(){
|
Route::get('/dokumentacja', function(){
|
||||||
return view('documents');
|
return view('documents');
|
||||||
@ -49,6 +46,10 @@ Route::get('/logout', 'SessionsController@destroy');
|
|||||||
Route::get('/jednostka', 'fireStationController@create');
|
Route::get('/jednostka', 'fireStationController@create');
|
||||||
Route::post('/jednostka', 'fireStationController@store');
|
Route::post('/jednostka', 'fireStationController@store');
|
||||||
|
|
||||||
|
Route::get('/strazacy', 'fireFightersController@create');
|
||||||
|
Route::get('/strazacy/add', 'fireFightersController@addForm');
|
||||||
|
Route::post('/strazacy', 'fireFightersController@store');
|
||||||
|
|
||||||
//Auth::routes();
|
//Auth::routes();
|
||||||
//
|
//
|
||||||
//Route::get('/home', 'HomeController@index')->name('home');
|
//Route::get('/home', 'HomeController@index')->name('home');
|
||||||
|
Loading…
Reference in New Issue
Block a user