Dodano usuwanie sprzętu i usuwanie pojazdów. Poprawki przy dodawaniu pojazdów.
This commit is contained in:
parent
e23f514556
commit
8b42974d18
@ -12,7 +12,7 @@ class EquipmentController extends Controller
|
|||||||
|
|
||||||
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||||
$equipment = DB::table('equipment')->where("fireStationID", '=', auth()->user()->fireStationID)
|
$equipment = DB::table('equipment')->where("fireStationID", '=', auth()->user()->fireStationID)
|
||||||
->get();
|
->whereNull('deleted_at')->get();
|
||||||
return view("equipment", ["equipment" => $equipment]);
|
return view("equipment", ["equipment" => $equipment]);
|
||||||
} else{
|
} else{
|
||||||
return view('equipment');
|
return view('equipment');
|
||||||
@ -83,6 +83,13 @@ class EquipmentController extends Controller
|
|||||||
$equipment-> parameter = $request-> parameter;
|
$equipment-> parameter = $request-> parameter;
|
||||||
$equipment->save();
|
$equipment->save();
|
||||||
|
|
||||||
return EquipmentController::create();
|
return redirect()->to('/sprzet');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
equipment::where('id',$id)->delete();
|
||||||
|
|
||||||
|
return redirect()->to('/sprzet');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,11 @@ use Carbon\Carbon; // formatowanie daty
|
|||||||
|
|
||||||
function formatDate($date)
|
function formatDate($date)
|
||||||
{
|
{
|
||||||
$fdate = Carbon::parse($date);
|
if ($date == null)
|
||||||
return $fdate;
|
return $date;
|
||||||
|
else
|
||||||
|
$fdate = Carbon::parse($date);
|
||||||
|
return $fdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
class VehiclesController extends Controller
|
class VehiclesController extends Controller
|
||||||
@ -19,7 +22,7 @@ class VehiclesController extends Controller
|
|||||||
|
|
||||||
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||||
$vehicles = DB::table('vehicles')->where("fireStationID", '=', auth()->user()->fireStationID)
|
$vehicles = DB::table('vehicles')->where("fireStationID", '=', auth()->user()->fireStationID)
|
||||||
->get();
|
->whereNull('deleted_at')->get();
|
||||||
return view("vehicles", ["vehicles" => $vehicles]);
|
return view("vehicles", ["vehicles" => $vehicles]);
|
||||||
} else{
|
} else{
|
||||||
return view('vehicles');
|
return view('vehicles');
|
||||||
@ -30,7 +33,6 @@ class VehiclesController extends Controller
|
|||||||
public function addForm(){
|
public function addForm(){
|
||||||
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||||
return view('vehiclesAdd');
|
return view('vehiclesAdd');
|
||||||
|
|
||||||
} else return view("login");
|
} else return view("login");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,32 +40,25 @@ class VehiclesController extends Controller
|
|||||||
{
|
{
|
||||||
if(auth()->user() != null && auth()->user()->fireStationID != null )
|
if(auth()->user() != null && auth()->user()->fireStationID != null )
|
||||||
{
|
{
|
||||||
//$userFireStation = auth()->user()->fireStationID;
|
|
||||||
//$fireFighterFireStation = DB::table('users')->where("id", $id)->value('fireStationID');
|
|
||||||
//$fireStationCreatorId = DB::table('fireStations')->where("id", $userFireStation)->value('creatorID');
|
|
||||||
|
|
||||||
$vehicle = DB::table('vehicles')->where("id", $id)->first();
|
|
||||||
|
|
||||||
|
$vehicle = DB::table('vehicles')->where("id", $id)->first();
|
||||||
return view('vehiclesEdit', ["vehicle" => $vehicle]);
|
return view('vehiclesEdit', ["vehicle" => $vehicle]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return "Brak dostepu";
|
return "Brak dostepu";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function store(){
|
public function store(){
|
||||||
$this->validate(request(), [
|
$this->validate(request(), [
|
||||||
|
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'productionYear' => 'digits:4',
|
'codename' => 'required',
|
||||||
'foamAgent' => 'numeric',
|
'productionYear' => 'digits:4|nullable',
|
||||||
'enginePower' => 'numeric',
|
'foamAgent' => 'numeric|nullable',
|
||||||
'crewNumber' => 'numeric',
|
'enginePower' => 'numeric|nullable',
|
||||||
'mass' => 'numeric',
|
'crewNumber' => 'numeric|nullable',
|
||||||
'chassisPoductionYear' => 'numeric',
|
'mass' => 'numeric|nullable',
|
||||||
//dokończyć! Wypytać Adriana które mają być required
|
'chassisPoductionYear' => 'numeric|nullable',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'required' => ':attribute jest wymagany(e).',
|
'required' => ':attribute jest wymagany(e).',
|
||||||
@ -105,13 +100,13 @@ class VehiclesController extends Controller
|
|||||||
$this->validate(request(), [
|
$this->validate(request(), [
|
||||||
|
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'productionYear' => 'digits:4',
|
'codename' => 'required',
|
||||||
'foamAgent' => 'numeric',
|
'productionYear' => 'digits:4|nullable',
|
||||||
'enginePower' => 'numeric',
|
'foamAgent' => 'numeric|nullable',
|
||||||
'crewNumber' => 'numeric',
|
'enginePower' => 'numeric|nullable',
|
||||||
'mass' => 'numeric',
|
'crewNumber' => 'numeric|nullable',
|
||||||
'chassisPoductionYear' => 'numeric',
|
'mass' => 'numeric|nullable',
|
||||||
//dokończyć! Wypytać Adriana które mają być required
|
'chassisPoductionYear' => 'numeric|nullable',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'required' => ':attribute jest wymagany(e).',
|
'required' => ':attribute jest wymagany(e).',
|
||||||
@ -144,6 +139,12 @@ class VehiclesController extends Controller
|
|||||||
$vehicle-> fireEnginePumpDescription = $request-> fireEnginePumpDescription;
|
$vehicle-> fireEnginePumpDescription = $request-> fireEnginePumpDescription;
|
||||||
$vehicle->save();
|
$vehicle->save();
|
||||||
|
|
||||||
return VehiclesController::create();
|
return redirect()->to('/pojazdy');;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
vehicle::where('id',$id)->delete();
|
||||||
|
return redirect()->to('/pojazdy');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
class equipment extends Model
|
class equipment extends Model
|
||||||
{
|
{
|
||||||
|
use SoftDeletes;
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
protected $table = 'equipment';
|
protected $table = 'equipment';
|
||||||
|
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
class vehicle extends Model
|
class vehicle extends Model
|
||||||
{
|
{
|
||||||
|
use SoftDeletes;
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
protected $table = 'vehicles';
|
protected $table = 'vehicles';
|
||||||
|
|
||||||
|
@ -18,24 +18,25 @@ class CreateVehiclesTable extends Migration
|
|||||||
$table->integer('fireStationID');
|
$table->integer('fireStationID');
|
||||||
$table->string('name', 45);
|
$table->string('name', 45);
|
||||||
$table->string('codename', 45);
|
$table->string('codename', 45);
|
||||||
$table->string('brand',45);
|
$table->string('brand',45)->nullable();
|
||||||
$table->string('registrationNumber', 15);
|
$table->string('registrationNumber', 15)->nullable();
|
||||||
$table->integer('productionYear');
|
$table->integer('productionYear')->nullable();
|
||||||
$table->date('examExpirationDate'); //Data ważności przegladu
|
$table->date('examExpirationDate')->nullable(); //Data ważności przegladu
|
||||||
$table->date('insuranceExpirationDate');
|
$table->date('insuranceExpirationDate')->nullable();
|
||||||
$table->string('driveType',45); //układ napędowy
|
$table->string('driveType',45)->nullable(); //układ napędowy
|
||||||
$table->string('chassisType',45); //typ podwozia
|
$table->string('chassisType',45)->nullable(); //typ podwozia
|
||||||
$table->string('bodyProducer',45); //producent nadwozia
|
$table->string('bodyProducer',45)->nullable(); //producent nadwozia
|
||||||
$table->integer('crewNumber');
|
$table->integer('crewNumber')->nullable();
|
||||||
$table->integer('foamAgent'); //Ilość środka pianotwórczego w litrach
|
$table->integer('foamAgent')->nullable(); //Ilość środka pianotwórczego w litrach
|
||||||
$table->integer('enginePower'); //Moc silnika w kW
|
$table->integer('enginePower')->nullable(); //Moc silnika w kW
|
||||||
$table->integer('mass'); //Masa całkowita pojazdu
|
$table->integer('mass')->nullable(); //Masa całkowita pojazdu
|
||||||
$table->string('chassisNumber');
|
$table->string('chassisNumber')->nullable();
|
||||||
$table->string('engineNumber');
|
$table->string('engineNumber')->nullable();
|
||||||
$table->string('fuelType',45);
|
$table->string('fuelType',45)->nullable();
|
||||||
$table->integer('chassisPoductionYear');
|
$table->integer('chassisPoductionYear')->nullable();
|
||||||
$table->date('entryIntoServiceDate');
|
$table->date('entryIntoServiceDate')->nullable();
|
||||||
$table->string('fireEnginePumpDescription');// Opis autopompy
|
$table->string('fireEnginePumpDescription')->nullable();// Opis autopompy
|
||||||
|
$table->softDeletes();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class CreateEquipmentTable extends Migration
|
|||||||
$table->string('name', 45);
|
$table->string('name', 45);
|
||||||
$table->integer('amount');
|
$table->integer('amount');
|
||||||
$table->string('parameter', 45)->nullable();
|
$table->string('parameter', 45)->nullable();
|
||||||
$table->boolean('deleted')->default(0);
|
$table->softDeletes();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
@if( auth()->user()->fireStationID == NULL)
|
@if( auth()->user()->fireStationID == NULL)
|
||||||
Jednostka nie istnieje
|
Jednostka nie istnieje
|
||||||
@else
|
@else
|
||||||
|
<p align='center'>
|
||||||
<table class='firefighterViewTable'>
|
<table class='firefighterViewTable'>
|
||||||
<tr class='table-header'>
|
<tr class='table-header'>
|
||||||
<td>Nazwa</td>
|
<td>Nazwa</td>
|
||||||
@ -24,13 +24,20 @@
|
|||||||
<td>Param. charakterystyczny</td>
|
<td>Param. charakterystyczny</td>
|
||||||
@foreach($equipment as $item)
|
@foreach($equipment as $item)
|
||||||
<tr>
|
<tr>
|
||||||
|
<form action="{{ route('equipment.destroy', $item->id)}}" method="post">
|
||||||
<td id="name{{ $item->id }}">{{ $item->name }}</td>
|
<td id="name{{ $item->id }}">{{ $item->name }}</td>
|
||||||
<td id="amount{{ $item->id }}">{{ $item->amount }}</td>
|
<td id="amount{{ $item->id }}">{{ $item->amount }}</td>
|
||||||
<td id="parameter{{ $item->id }}">{{ $item->parameter }}</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>
|
<td><a href="{{ URL::asset('sprzet/edit/'.$item->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td>
|
||||||
|
<td>
|
||||||
|
{{ csrf_field() }}
|
||||||
|
@method('DELETE')
|
||||||
|
<button class="btn btn-danger" type="submit">Usuń</button>
|
||||||
|
</form></td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</table>
|
||||||
|
</p>
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
@else
|
@else
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
$lp = $lp + 1
|
$lp = $lp + 1
|
||||||
@endphp
|
@endphp
|
||||||
<tr>
|
<tr>
|
||||||
|
<form action="{{ route('vehicles.destroy', $vehicle->id)}}" method="post">
|
||||||
<td>{{ $lp }}</td>
|
<td>{{ $lp }}</td>
|
||||||
<td id="name{{ $vehicle->id }}">{{ $vehicle->name }}</td>
|
<td id="name{{ $vehicle->id }}">{{ $vehicle->name }}</td>
|
||||||
<td id="brand{{ $vehicle->id }}">{{ $vehicle->brand }}</td>
|
<td id="brand{{ $vehicle->id }}">{{ $vehicle->brand }}</td>
|
||||||
@ -46,6 +47,11 @@
|
|||||||
<td id="examExpirationDate{{ $vehicle->id }}">{{ $vehicle->examExpirationDate }}</td>
|
<td id="examExpirationDate{{ $vehicle->id }}">{{ $vehicle->examExpirationDate }}</td>
|
||||||
<td id="insuranceExpirationDate{{ $vehicle->id }}">{{ $vehicle->insuranceExpirationDate }}</td>
|
<td id="insuranceExpirationDate{{ $vehicle->id }}">{{ $vehicle->insuranceExpirationDate }}</td>
|
||||||
<td><a href="{{ URL::asset('pojazdy/edit/'.$vehicle->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td>
|
<td><a href="{{ URL::asset('pojazdy/edit/'.$vehicle->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td>
|
||||||
|
<td>
|
||||||
|
{{ csrf_field() }}
|
||||||
|
@method('DELETE')
|
||||||
|
<button class="btn btn-danger" type="submit">Usuń</button>
|
||||||
|
</form></td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</table>
|
||||||
|
@ -61,13 +61,14 @@ Route::get('/pojazdy/add', 'VehiclesController@addForm');
|
|||||||
Route::post('/pojazdy', 'VehiclesController@store');
|
Route::post('/pojazdy', 'VehiclesController@store');
|
||||||
Route::get('/pojazdy/edit/{id}', 'VehiclesController@editForm');
|
Route::get('/pojazdy/edit/{id}', 'VehiclesController@editForm');
|
||||||
Route::post('/pojazdy/edit', 'VehiclesController@update');
|
Route::post('/pojazdy/edit', 'VehiclesController@update');
|
||||||
|
Route::resource('vehicles', 'VehiclesController');
|
||||||
|
|
||||||
Route::get('/sprzet', 'EquipmentController@create');
|
Route::get('/sprzet', 'EquipmentController@create');
|
||||||
Route::get('/sprzet/add', 'EquipmentController@addForm');
|
Route::get('/sprzet/add', 'EquipmentController@addForm');
|
||||||
Route::post('/sprzet', 'EquipmentController@store');
|
Route::post('/sprzet', 'EquipmentController@store');
|
||||||
Route::get('/sprzet/edit/{id}', 'EquipmentController@editForm');
|
Route::get('/sprzet/edit/{id}', 'EquipmentController@editForm');
|
||||||
Route::post('/sprzet/edit', 'EquipmentController@update');
|
Route::post('/sprzet/edit', 'EquipmentController@update');
|
||||||
|
Route::resource('equipment', 'EquipmentController');
|
||||||
|
|
||||||
Route::get('register/verify/{confirmationCode}', [
|
Route::get('register/verify/{confirmationCode}', [
|
||||||
'as' => 'confirmation_path',
|
'as' => 'confirmation_path',
|
||||||
|
Loading…
Reference in New Issue
Block a user