public function store(Request $request, Responder $responder)
 {
     return $responder->validateAndRespond($request->all(), ['community_id' => 'required|numeric', 'name' => 'required', 'email' => 'required|email', 'phone' => 'numeric', 'floor_plan_id' => 'numeric'], function ($response) use($request) {
         $checkAvailabilityLead = new Models\CheckAvailabilityLead();
         $checkAvailabilityLead->community_id = $request->get('community_id');
         $checkAvailabilityLead->name = $request->get('name');
         $checkAvailabilityLead->email = $request->get('email');
         $checkAvailabilityLead->phone = $request->get('phone');
         $checkAvailabilityLead->floor_plan_id = $request->get('floor_plan_id');
         if (!$checkAvailabilityLead->save()) {
             $response->fails = true;
             $response->messages = ['DB', 'Problem sending message. Please try again.'];
             return $response;
         }
         $community = Models\Community\Community::find($checkAvailabilityLead->community_id);
         $createdAt = new \DateTime($checkAvailabilityLead->created_at);
         $floorPlan = Models\FloorPlan\FloorPlan::find($checkAvailabilityLead->floor_plan_id);
         $emails = explode(',', $community->tRefFriendLeadEmails);
         foreach ($emails as $email) {
             $validator = \Validator::make(['email' => $email], ['email' => 'email|required']);
             if (!$validator->fails()) {
                 try {
                     \App\RExpress\Email\EmailManager::send(['template' => 'checkAvailabilityLead.emails.default', 'params' => ['communityUrl' => $community->vCommunityURL, 'name' => $checkAvailabilityLead->name, 'email' => $checkAvailabilityLead->email, 'phone' => $checkAvailabilityLead->phone, 'floorPlanLabel' => $floorPlan->label, 'createdAt' => $createdAt->format('F j, Y \\a\\t g:ia')], 'to' => trim($email), 'subject' => 'Check Availability Lead submitted at your website ' . $community->vCommunityURL]);
                 } catch (\Exception $e) {
                 }
             }
         }
         return $response;
     });
 }
 public function store($communityId, Request $request, Responder $responder)
 {
     $rules = ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email', 'phone_number' => 'numeric', 'apartment_id' => 'required|numeric'];
     return $responder->validateAndRespond($request->all(), $rules, function ($response) use($request) {
         $pets = 0;
         $permission = 0;
         if ($request->has('pets')) {
             $pets = $request->get('pets');
         }
         if ($request->has('permission')) {
             $permission = $request->get('permission');
         }
         $maintenanceRequest = new \App\RExpress\Models\MaintenanceRequest\MaintenanceRequest();
         $maintenanceRequest->first_name = $request->get('first_name');
         $maintenanceRequest->last_name = $request->get('last_name');
         $maintenanceRequest->email = $request->get('email');
         $maintenanceRequest->phone_number = $request->get('phone_number');
         $maintenanceRequest->apartment_id = $request->get('apartment_id');
         $maintenanceRequest->pets = $pets;
         $maintenanceRequest->permission = $permission;
         $maintenanceRequest->description = $request->get('description');
         if (!$maintenanceRequest->save()) {
             $response->fails = true;
             $response->message = ['DB' => 'Problem storing data.'];
         } else {
             $response->payload = $maintenanceRequest;
         }
         return $response->json();
     });
 }
 public function destroy($id, Responder $responder)
 {
     $item = \App\RExpress\Models\Gallery\GalleryItem::find($id);
     if (!$item->delete()) {
         $responder->fails = true;
         $responder->messages = ['DB', 'Problem deleting record from database'];
         return $responder->json();
     }
     $uploadDir = 'uploads/galleryInstances/' . $item->gallery_instance_id . '/' . $item->filename;
     unlink($uploadDir);
     return $responder->json();
 }
 public function index($commuintyIds, Responder $responder)
 {
     $commuintyIds = explode(',', $commuintyIds);
     $news = [];
     $events = [];
     foreach ($commuintyIds as $id) {
         $communityNewsItems = Models\Community\CommunityNews::with('news')->where('iCommunityId', '=', $id)->get()->toArray();
         foreach ($communityNewsItems as $item) {
             $news[] = $item;
         }
     }
     foreach ($commuintyIds as $id) {
         $communityEventItems = Models\Community\CommunityEvent::with('event')->where('iCommunityId', '=', $commuintyIds[0])->get()->toArray();
         foreach ($communityEventItems as $item) {
             $events[] = $item;
         }
     }
     $merged = array_merge($news, $events);
     return $responder->respondWithPayload($merged);
 }
 public function store(Request $request, Responder $responder)
 {
     return $responder->validateAndRespond($request->all(), ['comment' => 'required'], function ($response) use($request) {
         $comment = new MaintenanceRequest\MaintenanceRequestComment();
         $comment->comment = $request->get('comment');
         $comment->maintenance_request_id = $request->get('maintenance_request_id');
         $comment->created_by = $request->get('created_by');
         $comment->new = 1;
         if (!$comment->save()) {
             $response->fails = true;
             $response->messages = ['DB' => 'Problem saving, please try again.'];
         } else {
             try {
                 $this->sendNotification($comment);
             } catch (\Exception $e) {
             }
             $response->payload->comment = $comment;
         }
         return $response->json();
     });
 }
 public function index($communityId, Responder $responder)
 {
     $community = Community\Community::with('communityHours')->with('enabledInterfaces')->find($communityId);
     return $responder->respondWithPayload($community);
 }
 public function index($communityId, Responder $responder)
 {
     $contactFormLeads = Community\ContactFormLead::where('community_id', '=', $communityId)->get();
     return $responder->respondWithPayload($contactFormLeads);
 }
 public function index(Responder $responder)
 {
     return $responder->respondWithPayload(Community\Community::all());
 }