Ejemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $picture = Picture::find($id);
     $picture->fill($request->all());
     $picture->save();
     return back()->withMessage('Picture is updated!');
 }
Ejemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $user = Auth::user();
     $pic = Picture::find($id);
     $gallery = $pic->gallery()->first();
     $picture = Picture::whereIn('gallery_id', function ($query) use($user) {
         $query->select('id')->from('galleries')->where('user_id', $user->id);
     })->where('id', $id)->first();
     if (!$picture) {
         return response()->json(['status' => 'error'], 422);
     }
     $picture->delete();
     $pics = $gallery->pictures;
     return response()->json(['data' => $pics->toArray()]);
 }
 public function deletePicture($id)
 {
     $del = Picture::find($id);
     File::delete($del->url);
     $del->delete();
 }
Ejemplo n.º 4
0
function get_all_images_from_property_id($property_id)
{
    /* Find the junction table entries for pictures of this property */
    $photo_ids = PropertyPictureBridge::where('property_id', $property_id)->get();
    $images = array();
    /* Get all the photos of this property */
    if (count($photo_ids) < 1) {
        $placeholder = new Picture();
        $placeholder->url = env('PLACEHOLDER_IMAGE_URL');
        $placeholder->cloudinary_public_id = env('PLACEHOLDER_IMAGE_PUBLIC_ID');
        array_push($images, $placeholder);
    } else {
        foreach ($photo_ids as $photo_id) {
            array_push($images, Picture::find($photo_id->picture_id));
        }
    }
    return $images;
}
Ejemplo n.º 5
0
 public function searchPlaces(Request $request)
 {
     $data = $request->all();
     $properties = DB::table('properties')->where('owner_id', '!=', Auth::id());
     if ($request->has('city')) {
         $city = City::where('name', $data['city'])->first();
         $properties = $properties->where('city_id', '=', $city->id);
     }
     if ($request->has('district')) {
         $district = District::where('name', $data['district'])->first();
         $properties = $properties->where('district_id', '=', $district->id);
     }
     if ($request->has('type')) {
         $properties = $properties->where('type', '=', $data['type']);
     }
     if ($request->has('min_occupancy')) {
         $properties = $properties->where('max_occupancy', '>=', $data['min_occupancy']);
     }
     if ($request->has('max_occupancy')) {
         $properties = $properties->where('max_occupancy', '<=', $data['max_occupancy']);
     }
     if ($request->has('min_price_per_night')) {
         $properties = $properties->where('price_per_night', '>=', $data['min_price_per_night']);
     }
     if ($request->has('max_price_per_night')) {
         $properties = $properties->where('price_per_night', '<=', $data['max_price_per_night']);
     }
     $properties = $properties->join('property_features', 'properties.id', '=', 'property_features.property_id');
     if ($request->has('kitchen')) {
         $properties = $properties->where('kitchen', '=', on2true($data['kitchen']));
     }
     if ($request->has('internet')) {
         $properties = $properties->where('internet', '=', on2true($data['internet']));
     }
     if ($request->has('tv')) {
         $properties = $properties->where('tv', '=', on2true($data['tv']));
     }
     if ($request->has('essentials')) {
         $properties = $properties->where('essentials', '=', on2true($data['essentials']));
     }
     if ($request->has('shampoo')) {
         $properties = $properties->where('shampoo', '=', on2true($data['shampoo']));
     }
     if ($request->has('heating')) {
         $properties = $properties->where('heating', '=', on2true($data['heating']));
     }
     if ($request->has('air_conditioning')) {
         $properties = $properties->where('air_conditioning', '=', on2true($data['air_conditioning']));
     }
     if ($request->has('washer')) {
         $properties = $properties->where('washer', '=', on2true($data['washer']));
     }
     if ($request->has('dryer')) {
         $properties = $properties->where('dryer', '=', on2true($data['dryer']));
     }
     if ($request->has('free_parking_on_premises')) {
         $properties = $properties->where('free_parking_on_premises', '=', on2true($data['free_parking_on_premises']));
     }
     if ($request->has('wireless_internet')) {
         $properties = $properties->where('wireless_internet', '=', on2true($data['wireless_internet']));
     }
     if ($request->has('cable_tv')) {
         $properties = $properties->where('cable_tv', '=', on2true($data['cable_tv']));
     }
     if ($request->has('breakfast')) {
         $properties = $properties->where('breakfast', '=', on2true($data['breakfast']));
     }
     if ($request->has('pets_allowed')) {
         $properties = $properties->where('pets_allowed', '=', on2true($data['pets_allowed']));
     }
     if ($request->has('family_kid_friendly')) {
         $properties = $properties->where('family_kid_friendly', '=', on2true($data['family_kid_friendly']));
     }
     if ($request->has('suitable_for_events')) {
         $properties = $properties->where('suitable_for_events', '=', on2true($data['suitable_for_events']));
     }
     if ($request->has('smoking_allowed')) {
         $properties = $properties->where('smoking_allowed', '=', on2true($data['smoking_allowed']));
     }
     if ($request->has('wheelchair_accessible')) {
         $properties = $properties->where('wheelchair_accessible', '=', on2true($data['wheelchair_accessible']));
     }
     if ($request->has('elevator_in_building')) {
         $properties = $properties->where('elevator_in_building', '=', on2true($data['elevator_in_building']));
     }
     if ($request->has('indoor_fireplace')) {
         $properties = $properties->where('indoor_fireplace', '=', on2true($data['indoor_fireplace']));
     }
     if ($request->has('buzzer_wireless_intercom')) {
         $properties = $properties->where('buzzer_wireless_intercom', '=', on2true($data['buzzer_wireless_intercom']));
     }
     if ($request->has('doorman')) {
         $properties = $properties->where('doorman', '=', on2true($data['doorman']));
     }
     if ($request->has('pool')) {
         $properties = $properties->where('pool', '=', on2true($data['pool']));
     }
     if ($request->has('hot_tub')) {
         $properties = $properties->where('hot_tub', '=', on2true($data['hot_tub']));
     }
     if ($request->has('gym')) {
         $properties = $properties->where('gym', '=', on2true($data['gym']));
     }
     if ($request->has('feature_24_hour_check_in')) {
         $properties = $properties->where('feature_24_hour_check_in', '=', on2true($data['feature_24_hour_check_in']));
     }
     if ($request->has('hangers')) {
         $properties = $properties->where('hangers', '=', on2true($data['hangers']));
     }
     if ($request->has('iron')) {
         $properties = $properties->where('iron', '=', on2true($data['iron']));
     }
     if ($request->has('hair_dryer')) {
         $properties = $properties->where('hair_dryer', '=', on2true($data['hair_dryer']));
     }
     if ($request->has('laptop_friendly_workspace')) {
         $properties = $properties->where('laptop_friendly_workspace', '=', on2true($data['laptop_friendly_workspace']));
     }
     $properties = $properties->get();
     foreach ($properties as $property) {
         $property->id = $property->property_id;
         $property->city_name = City::find($property->city_id)->name;
         $photo_ids = PropertyPictureBridge::where('property_id', $property->id)->get();
         if (count($photo_ids) < 1) {
             $property->image_url = env('PLACEHOLDER_IMAGE_URL');
         } else {
             $property->image_url = Picture::find($photo_ids[0]->picture_id)->url;
         }
     }
     $cities = City::all();
     return redirect(url('/places/searchresult'))->with(['properties' => $properties, 'cities' => $cities]);
 }
Ejemplo n.º 6
0
 public function getPicture($id)
 {
     $picture = Picture::find($id);
     return view('single_picture')->with('picture', $picture)->with('gallery', $picture->gallery);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $query = Picture::find($id);
     $collections = collect($query);
     $filename = $collections->get('title');
     // default is config/filesystems.php
     $contents = Storage::get($filename);
     Storage::delete($filename);
     Picture::destroy($id);
     return redirect('picture');
     //return $contents;
 }