예제 #1
0
 public function photosRotate(Request $request, $id, $dir = 'right', $attachment_id)
 {
     $property = Property::withTrashed()->findOrFail($id);
     $this->attachmentBelongsToProperty($attachment_id, $property);
     $propertyAttachment = PropertyAttachment::findOrFail($attachment_id);
     $propertyAttachment->rotate($dir);
     if ($propertyAttachment->type == 'photo') {
         return redirect()->back()->with('messages', ['Photo has been rotated']);
     } elseif ($propertyAttachment->type == 'floorplan') {
         return redirect()->back()->with('messages', ['Floorplan has been rotated']);
     }
 }
예제 #2
0
 public function postPropertyPhotosReorder(Request $request, $id, $type)
 {
     $property = Property::findOrFail($id);
     $allowedAttachments = $property->attachments()->lists('id')->all();
     $count = 1;
     $ordered = [];
     foreach ($request->input('photos', []) as $photo) {
         if (in_array($photo, $allowedAttachments)) {
             $attachment = PropertyAttachment::findOrFail($photo);
             $attachment->update(['sort_order' => $count]);
             $ordered[] = $attachment->id;
             $count += 1;
         }
     }
     return response()->json($ordered);
 }