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