sprzęt - dodawanie, wyświetlanie i edycja
This commit is contained in:
parent
aab5c69c84
commit
e23f514556
88
app/Http/Controllers/EquipmentController.php
Normal file
88
app/Http/Controllers/EquipmentController.php
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\equipment;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class EquipmentController extends Controller
|
||||||
|
{
|
||||||
|
public function create(){
|
||||||
|
|
||||||
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||||
|
$equipment = DB::table('equipment')->where("fireStationID", '=', auth()->user()->fireStationID)
|
||||||
|
->get();
|
||||||
|
return view("equipment", ["equipment" => $equipment]);
|
||||||
|
} else{
|
||||||
|
return view('equipment');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addForm(){
|
||||||
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||||
|
return view('equipmentAdd');
|
||||||
|
|
||||||
|
} else return view("login");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editForm($id)
|
||||||
|
{
|
||||||
|
if(auth()->user() != null && auth()->user()->fireStationID != null )
|
||||||
|
{
|
||||||
|
|
||||||
|
$equipment = DB::table('equipment')->where("id", $id)->first();
|
||||||
|
|
||||||
|
return view('equipmentEdit', ["equipment" => $equipment]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return view("login");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(){
|
||||||
|
$this->validate(request(), [
|
||||||
|
|
||||||
|
'name' => 'required',
|
||||||
|
'amount' => 'required|numeric',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'required' => ':attribute jest wymagany(a).',
|
||||||
|
'numeric' => ':attribute powinna zawierać tylko cyfry.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$request = request();
|
||||||
|
$equipment = equipment::create([
|
||||||
|
'fireStationID' => auth()->user()->fireStationID,
|
||||||
|
'name' => $request-> name,
|
||||||
|
'amount' => $request-> amount,
|
||||||
|
'parameter' => $request-> parameter,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->to('/sprzet');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(){
|
||||||
|
$this->validate(request(), [
|
||||||
|
|
||||||
|
'name' => 'required',
|
||||||
|
'amount' => 'required|numeric',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'required' => ':attribute jest wymagany(a).',
|
||||||
|
'numeric' => ':attribute powinna zawierać tylko cyfry.'
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$request = request();
|
||||||
|
$equipment = equipment::find( $request->equipmentID);
|
||||||
|
$equipment-> name = $request-> name;
|
||||||
|
$equipment-> amount = $request-> amount;
|
||||||
|
$equipment-> parameter = $request-> parameter;
|
||||||
|
$equipment->save();
|
||||||
|
|
||||||
|
return EquipmentController::create();
|
||||||
|
}
|
||||||
|
}
|
16
app/equipment.php
Normal file
16
app/equipment.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class equipment extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $table = 'equipment';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'fireStationID','name', 'amount', 'parameter',
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateEquipmentTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('equipment', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->integer('fireStationID');
|
||||||
|
$table->string('name', 45);
|
||||||
|
$table->integer('amount');
|
||||||
|
$table->string('parameter', 45)->nullable();
|
||||||
|
$table->boolean('deleted')->default(0);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('equipment');
|
||||||
|
}
|
||||||
|
}
|
@ -161,6 +161,7 @@ return [
|
|||||||
'unitName' => 'nazwa jednostki',
|
'unitName' => 'nazwa jednostki',
|
||||||
'longitude' => 'długość geograficzna',
|
'longitude' => 'długość geograficzna',
|
||||||
'latitude' => 'szerokość geograficzna',
|
'latitude' => 'szerokość geograficzna',
|
||||||
|
'amount' => 'ilość'
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,14 +3,16 @@
|
|||||||
@section('left-menu')
|
@section('left-menu')
|
||||||
@parent
|
@parent
|
||||||
<ul>
|
<ul>
|
||||||
<li>Dodaj<img src="img/left_menu_icon/add.png"></li>
|
<a href="/sprzet"><li>Sprzęt<img src="img/left_menu_icon/more.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>Usuń<img src="img/left_menu_icon/delete.png"></li>
|
{{-- <li>Usuń<img src="img/left_menu_icon/delete.png"></li> --}}
|
||||||
</ul>
|
</ul>
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
@section('center-area')
|
@section('center-area')
|
||||||
@parent
|
@parent
|
||||||
Strona w budowie
|
Strona w budowie
|
||||||
<p>Zawarte będą tutaj informację o umundurowaniu oraz sprzęcie jaki jest na wyposarzeniu strażnicy oraz informacje gdzie umundurowanie się znajduje(druhowie mundury koszarowe oraz galowe mają w w domach, informacja ta pozwoli na sprawdzenie np jakie są braki w umundurowaniu)</p>
|
<p>Zawarte będą tutaj informacje o umundurowaniu oraz sprzęcie jaki jest na wyposażeniu strażnicy oraz informacje gdzie umundurowanie się znajduje(druhowie mundury koszarowe oraz galowe mają w w domach, informacja ta pozwoli na sprawdzenie np jakie są braki w umundurowaniu).</p>
|
||||||
|
|
||||||
|
|
||||||
@stop
|
@stop
|
40
resources/views/equipment.blade.php
Normal file
40
resources/views/equipment.blade.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
@extends('layout.app')
|
||||||
|
|
||||||
|
@section('left-menu')
|
||||||
|
@parent
|
||||||
|
<ul>
|
||||||
|
<a href="sprzet/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>Usuń<img src="../img/left_menu_icon/delete.png"></li>
|
||||||
|
</ul>
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('center-area')
|
||||||
|
@parent
|
||||||
|
|
||||||
|
@if( auth()->check())
|
||||||
|
@if( auth()->user()->fireStationID == NULL)
|
||||||
|
Jednostka nie istnieje
|
||||||
|
@else
|
||||||
|
|
||||||
|
<table class='firefighterViewTable'>
|
||||||
|
<tr class='table-header'>
|
||||||
|
<td>Nazwa</td>
|
||||||
|
<td>Ilość</td>
|
||||||
|
<td>Param. charakterystyczny</td>
|
||||||
|
@foreach($equipment as $item)
|
||||||
|
<tr>
|
||||||
|
<td id="name{{ $item->id }}">{{ $item->name }}</td>
|
||||||
|
<td id="amount{{ $item->id }}">{{ $item->amount }}</td>
|
||||||
|
<td id="parameter{{ $item->id }}">{{ $item->parameter }}</td>
|
||||||
|
<td><a href="{{ URL::asset('sprzet/edit/'.$item->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
Brak autoryzacji
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@stop
|
36
resources/views/equipmentAdd.blade.php
Normal file
36
resources/views/equipmentAdd.blade.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
@extends('layout.app')
|
||||||
|
|
||||||
|
@section('left-menu')
|
||||||
|
@parent
|
||||||
|
<ul>
|
||||||
|
<a href="/sprzet/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>Usuń<img src="/./img/left_menu_icon/delete.png"></li>
|
||||||
|
</ul>
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('center-area')
|
||||||
|
@parent
|
||||||
|
<form method="POST" action="/sprzet">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Nazwa:</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="{{ old('name') }} ">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="amount">Ilość:</label>
|
||||||
|
<input type="text" class="form-control" id="amount" name="amount" value="{{ old('amount') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="parameter">Parametr charakterystyczny:</label>
|
||||||
|
<input type="text" class="form-control" id="parameter" name="parameter" value="{{ old('parameter') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zatwierdź</button>
|
||||||
|
</div>
|
||||||
|
@include('inc.formerrors')
|
||||||
|
</form>
|
||||||
|
@stop
|
38
resources/views/equipmentEdit.blade.php
Normal file
38
resources/views/equipmentEdit.blade.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
@extends('layout.app')
|
||||||
|
|
||||||
|
@section('left-menu')
|
||||||
|
@parent
|
||||||
|
<ul>
|
||||||
|
<a href="/sprzet/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>Usuń<img src="/./img/left_menu_icon/delete.png"></li>
|
||||||
|
</ul>
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('center-area')
|
||||||
|
@parent
|
||||||
|
<form method="POST" action="/sprzet/edit">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
|
||||||
|
<input type="hidden" class="form-control" name="equipmentID" value="{{ $equipment->id }}">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Nazwa:</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="{{ $equipment->name }} ">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="amount">Ilość:</label>
|
||||||
|
<input type="text" class="form-control" id="amount" name="amount" value="{{ $equipment->amount }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="parameter">Parametr charakterystyczny:</label>
|
||||||
|
<input type="text" class="form-control" id="parameter" name="parameter" value="{{ $equipment->parameter }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zatwierdź</button>
|
||||||
|
</div>
|
||||||
|
@include('inc.formerrors')
|
||||||
|
</form>
|
||||||
|
@stop
|
@ -63,6 +63,12 @@ Route::get('/pojazdy/edit/{id}', 'VehiclesController@editForm');
|
|||||||
Route::post('/pojazdy/edit', 'VehiclesController@update');
|
Route::post('/pojazdy/edit', 'VehiclesController@update');
|
||||||
|
|
||||||
|
|
||||||
|
Route::get('/sprzet', 'EquipmentController@create');
|
||||||
|
Route::get('/sprzet/add', 'EquipmentController@addForm');
|
||||||
|
Route::post('/sprzet', 'EquipmentController@store');
|
||||||
|
Route::get('/sprzet/edit/{id}', 'EquipmentController@editForm');
|
||||||
|
Route::post('/sprzet/edit', 'EquipmentController@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