forked from s421507/eOSP2
Edycja strazakow
This commit is contained in:
parent
e00f575f94
commit
a66e11509a
@ -16,7 +16,6 @@ class fireFightersController extends Controller
|
||||
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||
// $users = user::where("fireStationID", auth()->user()->fireStationID)->get();
|
||||
$users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID)->get();
|
||||
echo "<script type='text/javascript'>alert('test');</script>";
|
||||
return view("fireFighters", ["users" => $users]);
|
||||
} else{
|
||||
return view('fireFighters');
|
||||
@ -37,8 +36,11 @@ class fireFightersController extends Controller
|
||||
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||
$userFireStation = auth()->user()->fireStationID;
|
||||
$fireFighterFireStation = DB::table('users')->where("id", $id)->value('fireStationID');
|
||||
if($userFireStation == $fireFighterFireStation) {
|
||||
return view('fireFightersEdit');
|
||||
$fireStationCreatorId = DB::table('fireStations')->where("id", $userFireStation)->value('creatorID');
|
||||
|
||||
$fireFighter = DB::table('users')->where("id", $id)->first();
|
||||
if($userFireStation == $fireFighterFireStation && auth()->user()->id == $fireStationCreatorId) {
|
||||
return view('fireFightersEdit', ["fireFighter" => $fireFighter]);
|
||||
} else{
|
||||
return "Brak dostepu";
|
||||
}
|
||||
@ -88,6 +90,35 @@ class fireFightersController extends Controller
|
||||
return fireFightersController::create();
|
||||
}
|
||||
|
||||
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',
|
||||
],
|
||||
[
|
||||
'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();
|
||||
$fireFighter = User::find( $request->userID);
|
||||
$fireFighter-> name = $request->name;
|
||||
$fireFighter-> surname = $request->surname;
|
||||
$fireFighter-> PESEL = $request->PESEL;
|
||||
$fireFighter-> phoneNumber = $request->phoneNumber;
|
||||
$fireFighter->save();
|
||||
|
||||
return fireFightersController::create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
@ -49,6 +49,12 @@
|
||||
document.getElementById("userDegree"+id).style.backgroundColor = "#e6e6e6";
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function test(id){
|
||||
document.getElementById("editForm"+id).style.display="block";
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
||||
@ -81,9 +87,17 @@
|
||||
<td id="userFunction{{ $user->id }}">Zast. Naczelnika</td>
|
||||
<td id="userDegree{{ $user->id }}">Dowódca</td>
|
||||
<td id="userStatus{{ $user->id }}">@if( $user->statusID == 0) Czynny @else Wyłączony @endif</td>
|
||||
{{-- <td><a href="{{ URL::asset('strazacy/edit/'.$user->id) }}">Edytuj<input type="button" onclick="add({{$user->id}})" value="Edytuj"> </a></td>--}}
|
||||
<td><button class="editbtn" onclick="editUser({{$user->id}})">Edytuj</button></td>
|
||||
<td><a href="{{ URL::asset('strazacy/edit/'.$user->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td>
|
||||
</tr>
|
||||
{{-- <tr>--}}
|
||||
{{-- <form id="editForm{{$user->id}}" 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>--}}
|
||||
{{-- </form>--}}
|
||||
{{-- </tr>--}}
|
||||
@endforeach
|
||||
</table>"
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
@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>
|
||||
<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
|
||||
|
||||
|
@ -15,24 +15,26 @@
|
||||
@parent
|
||||
<form method="POST" action="/strazacy/edit">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<input type="hidden" class="form-control" name="userID" value="{{$fireFighter->id}}">
|
||||
<div class="form-group">
|
||||
<label for="name">Imię:</label>
|
||||
<input type="text" class="form-control" id="name" name="name" value="{{ old('name') }} ">
|
||||
<input type="text" class="form-control" id="name" name="name" value="{{ $fireFighter->name}}">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Nazwisko:</label>
|
||||
<input type="text" class="form-control" id="surname" name="surname" value="{{ old('surname') }}">
|
||||
<input type="text" class="form-control" id="surname" name="surname" value="{{ $fireFighter->surname }}">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Pesel:</label>
|
||||
<input type="text" class="form-control" id="PESEL" name="PESEL" value="{{ old('PESEL') }}">
|
||||
<input type="text" class="form-control" id="PESEL" name="PESEL" value="{{ $fireFighter->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') }}">
|
||||
<input type="text" class="form-control" id="phoneNumber" name="phoneNumber" value="{{ $fireFighter->phoneNumber }}">
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ Route::get('/strazacy', 'fireFightersController@create');
|
||||
Route::get('/strazacy/add', 'fireFightersController@addForm');
|
||||
Route::post('/strazacy', 'fireFightersController@store');
|
||||
Route::get('/strazacy/edit/{id}', 'fireFightersController@editForm');
|
||||
//Route::post('/strazacy/edit', '');
|
||||
Route::post('/strazacy/edit', 'fireFightersController@update');
|
||||
|
||||
Route::get('/jednostka', 'fireStationController@create');
|
||||
Route::post('/jednostka', 'fireStationController@store');
|
||||
|
Loading…
Reference in New Issue
Block a user