Example #1
0
 public function create()
 {
     $rented = Contract::select('property_id')->get();
     $renters = Renter::select('id', 'first_name', 'last_name')->get()->toArray();
     $properties = Property::select('id', 'address')->whereNotIn('id', $rented)->get()->toArray();
     return view('contracts.create', compact('rented', 'renters', 'properties'));
 }
 public function propertyCustomer()
 {
     $search = \Input::get('q');
     // AGENT
     if ($this->admin->role_id == 3) {
         if ($search) {
             $properties = \App\Property::select('Properties.*')->join('PropertyLanguages', 'PropertyLanguages.property_id', '=', 'Properties.id')->where('PropertyLanguages.locale', $this->lang)->where('PropertyLanguages.title', 'like', $search . '%')->where('Properties.user_id', $this->admin->id)->where('status', -2)->orderBy('Properties.created_at', 'desc')->paginate($this->limit);
         } else {
             $properties = \App\Property::where('user_id', $this->admin->id)->where('status', -2)->orderBy('created_at', 'desc')->paginate($this->limit);
         }
         // SUPER ADMIN
     } else {
         if ($search) {
             $properties = \App\Property::select('Properties.*')->join('PropertyLanguages', 'PropertyLanguages.property_id', '=', 'Properties.id')->where('PropertyLanguages.locale', $this->lang)->where('PropertyLanguages.title', 'like', $search . '%')->where('status', -2)->orderBy('Properties.created_at', 'desc')->paginate($this->limit);
         } else {
             $properties = \App\Property::orderBy('created_at', 'desc')->where('status', -2)->paginate($this->limit);
         }
     }
     $categories = \App\Category::orderBy('order', 'asc')->where('parent_id', 0)->get();
     return view('admin.pages.request-properties', compact('properties', 'categories'));
 }