/**
  * Update the specified resource in storage.
  * PUT /properties/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = array_except(Input::all(), '_method');
     $v = Validator::make(Input::All(), array('name' => 'required|max:50|', 'description' => 'required|max:400|min:10', 'ownerID' => 'required'));
     if ($v->passes()) {
         $properties = Property::find($id);
         $properties->update($input);
         $newprop_id = $id;
         foreach (Input::get('CBgroup1', array()) as $value) {
             $housedue = new Housedue();
             $housedue->propertyID = $newprop_id;
             $housedue->receivable = $value;
             $housedue->save();
         }
         return Redirect::route('admin.property.index')->withFlashMessage('The  Property has been updated successfully');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
 public function createProperty()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('name' => 'required|max:50|', 'ownerID' => 'required', 'CBgroup1' => 'required', 'agent_id' => 'required'));
     if ($v->passes()) {
         $agent_id = Input::get('agent_id');
         $properties = Owner::where('agent_id', $agent_id)->get();
         if (!$properties->isEmpty()) {
             $property = new Property();
             $property->name = Input::get('name');
             $property->ownerID = Input::get('ownerID');
             $property->agent_id = $agent_id;
             $property->save();
             $newprop = Property::where('name', Input::get('name'))->first();
             $newprop_id = $newprop->id;
             $payment = Input::get('CBgroup1');
             $fields = preg_split("/[\\s,]+/", $payment);
             $arrlength = count($fields);
             for ($x = 0; $x < $arrlength; $x++) {
                 $housedue = new Housedue();
                 $housedue->propertyID = $newprop_id;
                 $converted = ucfirst(preg_replace("/[[:blank:]]+/", " ", $fields[$x]));
                 $housedue->receivable = $converted;
                 $housedue->db_name = $fields[$x];
                 $housedue->save();
             }
             $noteProperty2 = array('error' => false, 'message' => 'Property Created Successfully');
             return $noteProperty2;
         }
         $noteProperty3 = array('error' => true, 'message' => 'Only owners are allowed to create properties');
         return $noteProperty3;
     }
     $noteProperty4 = array('error' => true, 'message' => $v->messages());
     return $noteProperty4;
 }