Exemplo n.º 1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $propertyId = $request->route('id');
     $property = Property::findOrFail($propertyId);
     if ($property->status != Property::STATUS_DRAFT) {
         //return redirect()->route('frontend.property.create');
     }
     return $next($request);
 }
Exemplo n.º 2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $propertyId = $request->route('id');
     $property = Property::findOrFail($propertyId);
     $order = $property->getCartOrder();
     if (empty($order)) {
         return redirect()->route('frontend.property.create');
     }
     return $next($request);
 }
Exemplo n.º 3
0
 public function getCurrentList()
 {
     $compareList = Session::get('properties_in_comparison', []);
     $return = [];
     foreach ($compareList as $propertyId) {
         $return[] = Property::findOrFail($propertyId);
     }
     $return = collect($return);
     return $return;
 }
Exemplo n.º 4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $propertyId = $request->route('id');
     $property = Property::findOrFail($propertyId);
     if ($property->user->id != $this->auth->user()->id) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->route('frontend.property.create');
         }
     }
     return $next($request);
 }
Exemplo n.º 5
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $rules = [];
     $routeName = $this->route()->getName();
     if ($this->route('id')) {
         $property = Property::findOrFail($this->route('id'));
     } else {
         $property = new Property();
     }
     if (in_array($routeName, ['frontend.property.create.process', 'frontend.property.edit.process'])) {
         $rules = $this->getCreateRules($property);
     } elseif (in_array($routeName, ['frontend.property.details.process'])) {
         $rules = $this->getDetailRules($property);
     } elseif (in_array($routeName, ['frontend.property.map.process'])) {
         $rules['latitude'] = 'required_if:point_map,1';
         $rules['longitude'] = 'required_if:point_map,1';
     } elseif (in_array($routeName, ['frontend.property.packages.process'])) {
         $allowedPackages = implode(',', Package::lists('id')->toArray());
         $rules['action'] = 'required';
         foreach ($this->input('action', []) as $idx => $action) {
             $rules['action.' . $idx] = 'in:' . $allowedPackages;
             $package = Package::findOrFail($action);
             $allowedFeatures = implode(',', $package->features->lists('id')->toArray());
             foreach ($this->input('features.' . $package->id, []) as $featureIdx => $feature) {
                 $rules['features.' . $package->id . '.' . $featureIdx] = 'in:' . $allowedFeatures;
             }
         }
     } elseif (in_array($routeName, ['frontend.property.review.process'])) {
         $allowedPaymentMethods = array_keys(Payment::getPaymentMethods(null, TRUE));
         $allowedPaymentMethods = implode(',', $allowedPaymentMethods);
         if ($this->input('action') == 'purchase') {
             $rules['agree_tc'] = 'required';
             $rules['payment_method'] = 'required|in:' . $allowedPaymentMethods;
         }
     }
     return $rules;
 }
Exemplo n.º 6
0
 public function getReplies(Request $request, $property_id)
 {
     $user = Auth::user();
     $property = Property::findOrFail($property_id);
     $conversation = $user->getPropertyConversation($property);
     $replies = $conversation->replies()->where('id', '>', $request->get('lastID'))->get();
     $return['chats'] = [];
     foreach ($replies as $reply) {
         $return['chats'][] = ['id' => $reply->id, 'class' => $reply->sender_id == $conversation->sender_id ? 'chat-self' : 'chat-reply', 'text' => $reply->message, 'time' => $reply->created_at->format('d M Y H:i')];
     }
     return response()->json($return);
 }
Exemplo n.º 7
0
 public function assignToAgent(Request $request, $id)
 {
     $property = Property::findOrFail($id);
     $backUrl = $request->get('backUrl', route('admin.property.index'));
     if ($request->isMethod('POST')) {
         $backUrl = $request->input('backUrl', route('admin.property.index'));
         //Get remaining schedules for this property
         $viewingSchedules = $property->viewingSchedules()->where('viewing_from', '>', Carbon::now())->get();
         $conversations = $property->conversations;
         if ($request->has('agent')) {
             $agent = User::findOrFail($request->input('agent'));
             $property->agentList()->associate($agent);
             foreach ($viewingSchedules as $viewingSchedule) {
                 $viewingSchedule->agent()->associate($agent);
                 $viewingSchedule->save();
             }
             foreach ($conversations as $conversation) {
                 $conversation->recipient()->associate($agent);
                 $conversation->save();
             }
             $message = 'Property, Viewing Schedules and Conversation have been assigned to ' . $agent->profile->singleName . '.';
         } else {
             $property->agentList()->dissociate();
             foreach ($viewingSchedules as $viewingSchedule) {
                 $viewingSchedule->agent()->dissociate();
                 $viewingSchedule->save();
             }
             foreach ($conversations as $conversation) {
                 $conversation->recipient()->dissociate();
                 $conversation->save();
             }
             $message = 'Property, Viewing Schedules and Conversation have been detached from Agent.';
         }
         $property->save();
         return redirect($backUrl)->with('messages', [$message]);
     }
     $agentOptions = AgentHelper::getAgentOptions();
     return view('admin.property.assign_to_agent', ['property' => $property, 'agentOptions' => $agentOptions, 'backUrl' => $backUrl]);
 }
Exemplo n.º 8
0
 public function getRemoveFromComparison($id)
 {
     $property = Property::findOrFail($id);
     PropertyCompareHelper::removeFromComparison($property);
     return redirect()->back()->with('messages', [trans('property.property_comparison.remove_message', ['name' => $property->property_name])]);
 }