Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $http, Residence $residence)
 {
     // save newly created residence data
     $residence->nickname = $http->nickname;
     $residence->address1 = $http->address1;
     $residence->address2 = $http->address2;
     $residence->city = $http->city;
     $residence->state = $http->state;
     $residence->zipcode = $http->zipcode;
     $residence->num_residents = $http->num_residents;
     $residence->monthly_rent = $http->rent;
     // save new residence to the database
     $residence->save();
     // insert relationship between authenticated user
     // and the newly created residence
     $residence->residents()->attach(Auth::user()->id);
     return redirect('residences');
 }
Exemplo n.º 2
0
 public function createResidence(Request $req, $confId)
 {
     if (!Entrust::can(PermissionNames::ConferenceRoomEdit($confId))) {
         return response("", 403);
     }
     $responses = DB::transaction(function () use($req, $confId) {
         $responses = [];
         foreach ($req->all() as $request) {
             $this->validateResidence($request);
             $residence = new Residence();
             $residence->name = $request['name'];
             $residence->location = $request['location'];
             $residence->conferenceID = $confId;
             $residence->save();
             $responses[] = ["id" => $residence->id, "name" => $residence->name];
         }
         return $responses;
     });
     Log::info("Created " . sizeof($responses) . " residences for conferences {$confId}.");
     return response()->json($responses);
 }