public function create($id)
 {
     $properties = Property::findOrFail($id);
     $housedues = Housedue::where('propertyID', $id)->get();
     $frequencies = Frequency::all();
     return View::make('backend.code.houses.create', compact('properties', 'frequencies', 'housedues'));
 }
 /**
  * Show the form for editing the specified resource.
  * GET /houses/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $houses = House::find($id);
     $getid = $houses->propertyID;
     $housedues = Housedue::where('propertyID', $getid)->get();
     $frequencies = Frequency::all();
     foreach ($housedues as $housedue) {
         $receivables = strtolower(preg_replace("/[[:blank:]]+/", "_", $housedue));
     }
     if (is_null($houses)) {
         return Redirect::route('houses.index');
     }
     return View::make('backend.code.houses.edit', compact('houses', 'frequencies', 'housedues'));
 }
 public function destroy($id)
 {
     Property::find($id)->delete();
     House::where('propertyID', $id)->delete();
     House::where('propertyID', $id)->delete();
     Housedue::where('propertyID', $id)->delete();
     return Redirect::route('admin.property.index');
 }
 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;
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /accountreceivables/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $house = Housedue::find($id);
     $house->delete();
     return Redirect::route('Housedue');
 }