forked from s421507/eOSP2
dodanie widoku profil użytkownika - wyświetlanie i edycja podstawowych danych, bez zmiany hasła
This commit is contained in:
parent
c2dd5a8929
commit
a2c0d85c01
72
app/Http/Controllers/userProfileController.php
Normal file
72
app/Http/Controllers/userProfileController.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use DB;
|
||||||
|
use App\User;
|
||||||
|
use App\Rules\Pesel;
|
||||||
|
|
||||||
|
class userProfileController extends Controller
|
||||||
|
{
|
||||||
|
public function create(){
|
||||||
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||||
|
$userData = DB::table('users')->where("users.id", '=', auth()->user()->id)
|
||||||
|
->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id')
|
||||||
|
->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id')
|
||||||
|
->select('users.id','users.name', 'users.surname', 'users.PESEL','users.phoneNumber', 'users.email', 'ranks.rank', 'unitFunctions.unitFunction', 'users.number')
|
||||||
|
->first();
|
||||||
|
return view("userProfile", ["userData" => $userData]);
|
||||||
|
} else{
|
||||||
|
return redirect()->to('/login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editForm()
|
||||||
|
{
|
||||||
|
if(auth()->user() != null && auth()->user()->fireStationID != null )
|
||||||
|
{
|
||||||
|
|
||||||
|
$userData = DB::table('users')->where("id", '=', auth()->user()->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
return view("userProfileEdit", ["userData" => $userData]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return redirect()->to('/login');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(){
|
||||||
|
$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,email,'.auth()->user()->id, //wymagaj unikalnego adresu email ale pozwól na zachowanie starego adresu
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'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::find( $request->userID);
|
||||||
|
$user-> name = $request->name;
|
||||||
|
$user-> surname = $request->surname;
|
||||||
|
$user-> PESEL = $request->PESEL;
|
||||||
|
$user-> phoneNumber = $request->phoneNumber;
|
||||||
|
$user-> email = $request->email;
|
||||||
|
$user-> changingID = auth()->user()-> id;
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
return redirect()->to('/userprofile');;
|
||||||
|
}
|
||||||
|
}
|
@ -15,10 +15,11 @@
|
|||||||
@if( auth()->check() )
|
@if( auth()->check() )
|
||||||
{{ auth()->user()->name }}
|
{{ auth()->user()->name }}
|
||||||
{{ auth()->user()->surname }}
|
{{ auth()->user()->surname }}
|
||||||
<a href="/logout">Logout</a>
|
<a href="/logout">Wyloguj</a>
|
||||||
|
<a href="/userprofile">Mój profil</a>
|
||||||
@else
|
@else
|
||||||
<a href="/login">Login</a>
|
<a href="/login">Zaloguj się</a>
|
||||||
<a href="/register">Register</a>
|
<a href="/register">Rejestracja</a>
|
||||||
@endif
|
@endif
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<div class="logo"><a href="/register"><img src="../img/logo.png"></a></div>
|
<div class="logo"><a href="/register"><img src="../img/logo.png"></a></div>
|
||||||
|
51
resources/views/userProfile.blade.php
Normal file
51
resources/views/userProfile.blade.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
@extends('layout.app')
|
||||||
|
|
||||||
|
@section('left-menu')
|
||||||
|
@parent
|
||||||
|
<ul>
|
||||||
|
<a href="/userprofile/edit"><li>Edytuj profil<img src="../img/left_menu_icon/edit.png"></li></a>
|
||||||
|
<a href="/userprofile/passwordchange"><li>Zmiana hasła<img src="../img/left_menu_icon/edit.png"></li></a>
|
||||||
|
</ul>
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('center-area')
|
||||||
|
@parent
|
||||||
|
|
||||||
|
@if( auth()->check())
|
||||||
|
<p align='center'>
|
||||||
|
<table class='firefighterViewTable'>
|
||||||
|
<tr>
|
||||||
|
<td>Imię i nazwisko:</td>
|
||||||
|
<td>{{ $userData->name }} {{ $userData->surname }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>PESEL:</td>
|
||||||
|
<td>{{ $userData->PESEL}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Nr telefonu:</td>
|
||||||
|
<td>{{ $userData->phoneNumber}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Adres e-mail:</td>
|
||||||
|
<td>{{ $userData->email}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Numer ewidencyjny:</td>
|
||||||
|
<td>{{ $userData->number}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Stopień:</td>
|
||||||
|
<td>{{ $userData->rank}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Funkcja:</td>
|
||||||
|
<td>{{ $userData->unitFunction}}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
@else
|
||||||
|
Brak autoryzacji
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@stop
|
45
resources/views/userProfileEdit.blade.php
Normal file
45
resources/views/userProfileEdit.blade.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
@extends('layout.app')
|
||||||
|
|
||||||
|
@section('left-menu')
|
||||||
|
@parent
|
||||||
|
<ul>
|
||||||
|
<a href="/userprofile/passwordchange"><li>Zmiana hasła<img src="../img/left_menu_icon/edit.png"></li></a>
|
||||||
|
</ul>
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('center-area')
|
||||||
|
@parent
|
||||||
|
<form method="POST" action="/userprofile/edit">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
|
||||||
|
<input type="hidden" class="form-control" name="userID" value="{{ $userData->id }}">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Imię:</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="{{ $userData->name }} ">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="amount">Nazwisko:</label>
|
||||||
|
<input type="text" class="form-control" id="surname" name="surname" value="{{ $userData->surname }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="parameter">PESEL:</label>
|
||||||
|
<input type="text" class="form-control" id="PESEL" name="PESEL" value="{{ $userData->PESEL }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="parameter">Numer telefonu:</label>
|
||||||
|
<input type="text" class="form-control" id="phoneNumber" name="phoneNumber" value="{{ $userData->phoneNumber }}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="parameter">Adres e-mail:</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="{{ $userData->email }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zatwierdź</button>
|
||||||
|
</div>
|
||||||
|
@include('inc.formerrors')
|
||||||
|
</form>
|
||||||
|
@stop
|
@ -74,6 +74,10 @@ Route::get('/sprzet/edit/{id}', 'EquipmentController@editForm');
|
|||||||
Route::post('/sprzet/edit', 'EquipmentController@update');
|
Route::post('/sprzet/edit', 'EquipmentController@update');
|
||||||
Route::resource('equipment', 'EquipmentController');
|
Route::resource('equipment', 'EquipmentController');
|
||||||
|
|
||||||
|
Route::get('/userprofile', 'userProfileController@create');
|
||||||
|
Route::get('/userprofile/edit', 'userProfileController@editForm');
|
||||||
|
Route::post('/userprofile/edit', 'userProfileController@update');
|
||||||
|
|
||||||
Route::get('register/verify/{confirmationCode}', [
|
Route::get('register/verify/{confirmationCode}', [
|
||||||
'as' => 'confirmation_path',
|
'as' => 'confirmation_path',
|
||||||
'uses' => 'RegistrationController@confirm'
|
'uses' => 'RegistrationController@confirm'
|
||||||
|
Loading…
Reference in New Issue
Block a user