forked from s421507/eOSP2
54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\fireStation;
|
|
|
|
|
|
class fireStationController extends Controller
|
|
{
|
|
public function create(){
|
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
|
$fireStation = fireStation::find(auth()->user()->fireStationID);
|
|
return view('unit', ["fireStation" => $fireStation]);
|
|
} else{
|
|
return view('unit');
|
|
}
|
|
}
|
|
public function store()
|
|
{
|
|
$this->validate(request(),[
|
|
|
|
]);
|
|
|
|
|
|
$request = request();
|
|
$jednostka = fireStation::create([
|
|
'name' => $request -> name,
|
|
'number' => $request -> number,
|
|
'voivodeship' => $request -> voivodeship,
|
|
'county' => $request -> county,
|
|
'community' => $request -> community,
|
|
'postOffice' => $request -> postOffice,
|
|
'zipCode' => $request -> zipCode,
|
|
'address' => $request -> address,
|
|
'latitude' => $request -> latitude,
|
|
'longitude' => $request -> longitude,
|
|
'KRS' => $request -> KRS,
|
|
'NIP' => $request -> NIP,
|
|
'phoneNumber' => $request -> phoneNumber,
|
|
'email' => $request -> email,
|
|
'creatorID' => auth()->user()->id,
|
|
'changingID' => auth()->user()->id
|
|
]);
|
|
|
|
$user = auth()->user();
|
|
$user->fireStationID = $jednostka->id;
|
|
$user->save();
|
|
|
|
return redirect()->to('/jednostka');
|
|
}
|
|
}
|