Ejemplo n.º 1
0
 public function index()
 {
     //get each propert from database
     $columns = array('address' => 'Address', 'city' => 'City', 'state' => 'State', 'beds' => 'Beds', 'baths' => 'Baths');
     $properties = Property::all();
     return view('properties.index', compact('properties', 'columns'));
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $properties = \App\Property::all();
     foreach ($properties as $property) {
         $property->delete();
     }
     dispatch((new RemoveUnrelatedImages())->onQueue('killImage'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     $contractor = User::with('keys')->findOrFail($id);
     $keys = Key::all();
     $properties = Property::all();
     return View('contractors.show', compact(['contractor', 'keys', 'properties']));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     //
     $key = Key::findOrFail($id);
     $contractors = User::all()->sortBy('full_name');
     $properties = Property::all();
     return View('keys.edit', compact(['key', 'contractors', 'properties']));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     if (rand(0, 1) == 1) {
         $url = "https://pixabay.com/api/?key=" . env('PIXABAY_API_KEY') . "&image_type=photo&category=buildings&safesearch=true&min_width=500";
         $json = file_get_contents($url);
         $json_data = json_decode($json, true);
         $pixa_json = $json_data['hits'];
         foreach ($pixa_json as $image) {
             $pictureUploadResult = \Cloudinary\Uploader::upload($image['webformatURL']);
             if ($pictureUploadResult == null) {
                 echo "Error uploading picture";
                 continue;
             }
             $picture = new Picture();
             $picture->description = "";
             $picture->url = $pictureUploadResult['secure_url'];
             $picture->cloudinary_public_id = $pictureUploadResult['public_id'];
             $picture->save();
             $junction = new PropertyPictureBridge();
             $all_properties = Property::all();
             $one_property = $all_properties[rand(0, count($all_properties) - 1)];
             $junction->property_id = $one_property->id;
             $junction->picture_id = $picture->id;
             $junction->save();
         }
     } else {
         $api_key = env('FLICKR_API_KEY');
         $query = 'new york city apartment';
         $url = "https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=" . $api_key . "&tags=" . urlencode($query) . "&safe_search=1&per_page=20&format=json";
         $json_data = file_get_contents($url);
         $json_data = substr($json_data, 14);
         $json_data = substr($json_data, 0, strlen($json_data) - 1);
         $json_data = json_decode($json_data, true);
         foreach ($json_data['photos']['photo'] as $photo) {
             $farm = $photo['farm'];
             $server = $photo['server'];
             $src = 'http://farm' . $farm . '.static.flickr.com/' . $server . '/' . $photo['id'] . '_' . $photo['secret'] . '_z.jpg';
             $pictureUploadResult = \Cloudinary\Uploader::upload($src);
             if ($pictureUploadResult == null) {
                 echo "Error uploading picture";
                 continue;
             }
             $picture = new Picture();
             $picture->description = "";
             $picture->url = $pictureUploadResult['secure_url'];
             $picture->cloudinary_public_id = $pictureUploadResult['public_id'];
             $picture->save();
             $junction = new PropertyPictureBridge();
             $all_properties = Property::all();
             $one_property = $all_properties[rand(0, count($all_properties) - 1)];
             $junction->property_id = $one_property->id;
             $junction->picture_id = $picture->id;
             $junction->save();
         }
     }
 }
Ejemplo n.º 6
0
 public function getAdminPanel()
 {
     $pageName = 'Dashboard';
     $users = Sentry::findAllUsers();
     $newUsers = new Collection($users);
     $userNumber = $newUsers->count();
     $propertyNumber = Property::all()->count();
     $soldPropertyNumber = Property::where('state', '=', 'sold')->count();
     $newsNumber = News::all()->count();
     return view('admin.adminIndex')->with(compact('pageName', 'userNumber', 'propertyNumber', 'soldPropertyNumber', 'newsNumber'));
 }
 public function getAddcolumns(Request $request)
 {
     $category = session('category');
     if ($category == null) {
         return redirect('admin/category/add');
     }
     $request->session()->flash('category', $category);
     $request->session()->put('root_categories', Category::where('parent_id', null)->get());
     $properties = Property::all();
     return view('admin.category.add_columns')->with('num', $category->num_columns)->with('properties', $properties);
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     // Load Undeposited Payments to Nav Bar
     view()->composer('inc.header', function ($view) {
         $view->with('undepositedfunds', \App\Payment::whereRaw('bank_deposits_id IS NULL')->get()->sum('amount'));
         $properties = \App\Property::all();
         $rents_due = 0;
         $deposits_due = 0;
         foreach ($properties as $p) {
             $rents_due += $p->rentBalance();
             $deposits_due += $p->depositBalance();
         }
         $view->with('rents_due', $rents_due);
         $view->with('deposits_due', $deposits_due);
         $view->with('properties', $properties);
     });
 }
Ejemplo n.º 9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $num_bookings = 50;
     $all_properties = \App\Property::all();
     $users = \App\User::all();
     $statuses = array('requested', 'confirmed', 'rejected');
     for ($i = 0; $i < $num_bookings; $i++) {
         $one_property = $all_properties[mt_rand(0, count($all_properties) - 1)];
         $one_customer = null;
         $customer_id_ok = false;
         while (!$customer_id_ok) {
             $one_customer = $users[mt_rand(0, count($users) - 1)];
             if ($one_customer->id != $one_property->owner_id) {
                 $customer_id_ok = true;
             }
         }
         $one_status = $statuses[mt_rand(0, count($statuses) - 1)];
         $booking_ok = false;
         $start = null;
         $end = null;
         while (!$booking_ok) {
             $start = $this->randomDate(date('2016-01-01'), "2016-04-30");
             $start_time_plus_one_day = strtotime($start);
             $start_time_plus_one_day = strtotime("+1 day", $start_time_plus_one_day);
             $start_time_plus_seven_days = strtotime($start);
             $start_time_plus_seven_days = strtotime("+7 day", $start_time_plus_seven_days);
             $end = $this->randomDate(date('Y-m-d', $start_time_plus_one_day), date('Y-m-d', $start_time_plus_seven_days));
             $select_statement = 'select * from bookings WHERE ' . "'" . $start . "'" . ' <= bookings.end AND ' . "'" . $end . "'" . ' >= start AND bookings.status = ' . "'" . 'confirmed' . "'" . 'AND bookings.property_id = ' . $one_property->id;
             $overlapping_bookings = DB::select($select_statement);
             if (count($overlapping_bookings) == 0) {
                 $booking_ok = true;
             }
         }
         $booking = new \App\Booking();
         $booking->customer_id = $one_customer->id;
         $booking->property_id = $one_property->id;
         $booking->start = $start;
         $booking->end = $end;
         $booking->status = $one_status;
         $booking->save();
     }
 }
Ejemplo n.º 10
0
         $rating_total = 0;
         foreach ($properties as $property) {
             $user->host_num_bookings_confirmed += count(Booking::where('property_id', $property->id)->where('status', 'confirmed')->get());
             $user->host_num_bookings_rejected += count(Booking::where('property_id', $property->id)->where('status', 'rejected')->get());
             $user->host_num_bookings_requested += count(Booking::where('property_id', $property->id)->where('status', 'requested')->get());
             $comments = Comment::where('property_id', $property->id)->get();
             foreach ($comments as $comment) {
                 $num_ratings += 1;
                 $rating_total += $comment->rating;
             }
         }
         if ($num_ratings > 0) {
             $user->overall_rating = (double) $rating_total / (double) $num_ratings;
         }
     }
     $properties = Property::all()->sortBy('created_at');
     foreach ($properties as $property) {
         $property->num_bookings_confirmed = count(Booking::where('property_id', $property->id)->where('status', 'confirmed')->get());
         $property->num_bookings_rejected = count(Booking::where('property_id', $property->id)->where('status', 'rejected')->get());
         $property->num_bookings_requested = count(Booking::where('property_id', $property->id)->where('status', 'requested')->get());
         $property->overall_rating = floatval(DB::select('SELECT AVG(rating) AS avg FROM comments WHERE property_id = ' . $property->id . ';')[0]->avg);
         $property->city_name = City::find($property->city_id)->name;
     }
     return view('admin_panel', ['users' => $users, 'properties' => $properties]);
 }));
 Route::get('/property/{property_id}', function ($property_id) {
     /* Get the property */
     $property = Property::find($property_id);
     /* Use property_id to find the feature/amenities row in the other table*/
     $amenities = PropertyFeatures::where('property_id', $property->id)->get()[0];
     /* Use the city_id to find the city name */
Ejemplo n.º 11
0
 public function undeposited(Property $property, Request $request)
 {
     $propertyid = $property->id;
     // return $propertyid;
     // (isset($propertyid)) ? $property = Property::find($propertyid) : $property = null;
     $rentpayments = Payment::where('payment_type', '<>', 'Deposit')->whereRaw('bank_deposits_id IS NULL')->whereHas('lease', function ($q) use($propertyid) {
         $q->join('apartments', function ($join) use($propertyid) {
             $join->on('apartments.id', '=', 'leases.apartment_id')->where('property_id', '=', $propertyid);
         });
     })->get();
     $depositpayments = Payment::where('payment_type', '=', 'Deposit')->whereRaw('bank_deposits_id IS NULL')->whereHas('lease', function ($q) use($propertyid) {
         $q->join('apartments', function ($join) use($propertyid) {
             $join->on('apartments.id', '=', 'leases.apartment_id')->where('property_id', '=', $propertyid);
         });
     })->get();
     $properties = Property::all();
     $title = 'Undeposited Funds';
     $title = $title . ": " . $property->name;
     return view('deposits.undeposited_funds', ['title' => $title, 'property' => $property, 'properties' => $properties, 'rentpayments' => $rentpayments, 'depositpayments' => $depositpayments]);
 }
Ejemplo n.º 12
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $properties = Property::all();
     return view('properties.index')->with(compact('properties'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $properties = Property::all();
     return View('properties.index', compact('properties'));
 }
Ejemplo n.º 14
0
 public function index()
 {
     $properties = \App\Property::all();
     return view('index', ['title' => 'Happy ' . \Carbon\Carbon::now()->format('l'), 'properties' => $properties]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $properties = Property::all();
     return view('property.index')->with('properties', $properties);
 }
 public function getIndex()
 {
     $properties = Property::all();
     return view('admin.property.properties')->with('properties', $properties);
 }