コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store($id, Request $request)
 {
     //a user can add a unit to  a building
     $building = Building::findOrFail($id);
     $unit = $building->units()->create($request->all());
     return redirect(url('/home'));
 }
コード例 #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(BuildingRequest $request, $id)
 {
     $input = $request->except('_method', '_token');
     $building = Building::findOrFail($id);
     if ($building->update($input)) {
         return redirect('/buildings');
     }
 }
コード例 #3
0
ファイル: LocationsRepository.php プロジェクト: Jemok/locate
 /**
  * Generate an address for a location
  * @param $location
  * @return string
  */
 private function generateAddress($location)
 {
     $locationName = $location->locationKeyCode;
     $locationId = $location->id;
     $location = $this->location->findOrFail($locationId);
     $levelId = $location->level_id;
     $level = $this->level_building->findOrFail($levelId);
     $levelName = $level->levelName;
     $building_id = $level->building_id;
     $building = $this->building->findOrFail($building_id);
     $buildingName = $building->buildingKeyCode;
     $street_id = $building->street_id;
     $street = $this->street->findOrFail($street_id);
     $streetName = $street->streetKeyCode;
     $agent_id = $street->agent_id;
     $this->agent_id = $agent_id;
     //$agent = $this->agent->findOrFail($agent_id);
     $agentName = \App\Agent::where('user_id', '=', $agent_id)->first()->agentName;
     return $buildingName . $levelName . $locationName . "-" . $streetName . " ( " . $agentName . " ) ";
 }
コード例 #4
0
 /**
  * Persist a building level to the database
  * @param $request
  * @param $id
  */
 public function persist($request, $id)
 {
     $building = $this->building->findOrFail($id);
     $building->levels()->create(['building_id' => $id, 'level_id' => $request->levelName, 'levelName' => $this->level->where('id', '=', $request->levelName)->first()->levelName]);
     $this->updateLevels($building);
 }
コード例 #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $building = Building::findOrFail($id);
     $building->delete();
     return redirect()->route('buildings.index')->with('message', 'Item deleted successfully.');
 }