Пример #1
0
 public function properties()
 {
     $qb = Property::active()->orderBy('checkout_at', 'DESC');
     $properties = $qb->get();
     $content = view('frontend.sitemap.properties', ['properties' => $properties])->render();
     return response($content, 200)->header('Content-Type', 'text/xml');
 }
Пример #2
0
 public function getXMLLamudi()
 {
     $return = [];
     $qb = Property::active();
     AddressHelper::addAddressQueryScope($qb);
     //By exclusive
     $qb->selectRaw('properties.*, IF(Pac.slug = \'exclusive\', 1, 0) as is_exclusive');
     $qb->leftJoin('package_property AS PP', 'PP.property_id', '=', 'properties.id')->leftJoin('packages AS Pac', 'PP.package_id', '=', 'Pac.id')->leftJoin('package_categories AS PC', 'PC.id', '=', 'Pac.package_category_id');
     $qb->groupBy('properties.id');
     $qb->orderBy('is_exclusive', 'DESC');
     $sellProperties = $qb->where('for_sell', 1)->get();
     foreach ($sellProperties as $property) {
         if ($property->hasThumbnail() || $property->hasFloorplan()) {
             $propertyData = $this->generatePropertyData($property, 'sell');
             $return[] = $propertyData;
         }
     }
     $rentProperties = $qb->where('for_rent', 1)->get();
     foreach ($rentProperties as $property) {
         if ($property->hasThumbnail() || $property->hasFloorplan()) {
             $propertyData = $this->generatePropertyData($property, 'rent');
             $return[] = $propertyData;
         }
     }
     return response()->xml($return, 200, [], 'Properties', null, 'Data');
 }
Пример #3
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);
 }
Пример #4
0
 public function deleteArea(Request $request, $id)
 {
     $propertyCount = Property::where('subdistrict', $id)->count();
     if ($propertyCount > 0) {
         return redirect()->back()->withErrors(['Area can\'t be deleted because it is used by Property.']);
     }
     $qb = DB::table('rajaongkir_indonesia_subdistricts')->where('subdistrict_id', $id)->delete();
     return redirect()->back()->with('messages', ['Area has been deleted.']);
 }
Пример #5
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);
 }
Пример #6
0
 public function getCurrentList()
 {
     $compareList = Session::get('properties_in_comparison', []);
     $return = [];
     foreach ($compareList as $propertyId) {
         $return[] = Property::findOrFail($propertyId);
     }
     $return = collect($return);
     return $return;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('properties', function (Blueprint $table) {
         $table->string('listing_code')->after('property_name')->nullable();
     });
     $properties = \GoProp\Models\Property::hasCheckout()->orderBy('checkout_at', 'ASC')->get();
     foreach ($properties as $property) {
         $property->generateListingCode();
         $property->save();
     }
 }
Пример #8
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);
 }
Пример #9
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::withTrashed()->findOrFail($propertyId);
     if (!$property->canEdit($this->auth->user())) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->back()->withErrors(['You are not authorized to do this action']);
         }
     }
     return $next($request);
 }
Пример #10
0
 public function getExclusiveProperties($take = 5)
 {
     $qb = Property::active()->with('type')->orderBy(DB::raw('RAND()'))->take($take);
     $sellQb = clone $qb;
     $sellExclusiveProperties = $sellQb->select(DB::raw('properties.*, "sell" AS exclusive_type'))->whereHas('packages', function ($query) {
         $query->whereHas('category', function ($query2) {
             $query2->where('slug', 'sell');
         });
         $query->where('slug', 'exclusive');
     })->get()->all();
     $rentQb = $qb;
     $rentExclusiveProperties = $qb->select(DB::raw('properties.*, "rent" AS exclusive_type'))->whereHas('packages', function ($query) {
         $query->whereHas('category', function ($query2) {
             $query2->where('slug', 'rent');
         });
         $query->where('slug', 'exclusive');
     })->get()->all();
     $properties = array_merge($rentExclusiveProperties, $sellExclusiveProperties);
     shuffle($properties);
     $properties = array_slice($properties, 0, $take);
     return $properties;
 }
Пример #11
0
 public function getDetailRules($property)
 {
     $certificateAllowedValues = implode(',', array_keys(Property::getCertificateLabel()));
     $rules['building_size'] = 'numeric|min:1';
     $rules['building_dimension.length'] = 'numeric|required_with:building_dimension.width';
     $rules['building_dimension.width'] = 'numeric|required_with:building_dimension.length';
     if ($property->type->slug != 'land') {
         $rules['building_size'] .= '|required';
     }
     $rules['land_size'] = 'numeric|min:1';
     $rules['land_dimension.length'] = 'numeric|required_with:land_dimension.width';
     $rules['land_dimension.width'] = 'numeric|required_with:land_dimension.length';
     if ($property->type->slug == 'land') {
         $rules['land_size'] .= '|required';
     }
     $rules['floor'] = 'numeric';
     $rules['certificate'] = 'in:' . $certificateAllowedValues;
     $rules['virtual_tour_url'] = 'url';
     //$rules['description'] = 'required|min:10|max:300';
     return $rules;
 }
Пример #12
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);
 }
Пример #13
0
 public function generateListingCode()
 {
     if (empty($this->checkout_at) || !empty($this->listing_code)) {
         abort(403, 'Can\'t generate listing code action.');
     }
     $getLastProperty = Property::withTrashed()->hasCheckout()->whereNotNull('listing_code')->orderBy(DB::raw('CAST(SUBSTR(listing_code, 6) as UNSIGNED)'), 'DESC')->whereRaw("DATE_FORMAT(checkout_at, '%m-%Y') = ?", [$this->checkout_at->format('m-Y')])->first();
     if ($getLastProperty) {
         $lastListingNumber = intval(substr($getLastProperty->listing_code, 6));
     } else {
         $lastListingNumber = 0;
     }
     $listingNumber = $lastListingNumber + 1;
     $currentDateCode = $this->checkout_at->format('ym');
     $this->listing_code = 'GO' . $currentDateCode . str_pad($listingNumber, 2, '0', STR_PAD_LEFT);
 }
Пример #14
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]);
 }
Пример #15
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])]);
 }
Пример #16
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $user = Auth::user();
     $propertyTypeAllowedValues = implode(',', PropertyType::lists('id')->all());
     $rentPriceTypeAllowedValues = implode(',', array_keys(Property::getRentTypeLabel()));
     $viewingSchedulesAllowedValues = implode(',', array_keys(Property::getViewingScheduleOptionLabel()));
     $propertyFurnishingAllowedValues = implode(',', array_keys(Property::getFurnishingLabel()));
     $orientationAllowedValues = implode(',', array_keys(Property::getOrientationLabel()));
     $propertyType = PropertyType::find($this->input('property_type_id'));
     if ($user->is('administrator')) {
         $rules['owner'] = 'required|email';
     }
     $rules['property_name'] = 'required';
     $rules['province'] = 'required';
     $rules['city'] = 'required';
     $rules['subdistrict'] = 'required';
     $rules['address'] = 'required';
     $rules['postal_code'] = '';
     $rules['property_type_id'] = 'required|in:' . $propertyTypeAllowedValues;
     $rules['garage_size'] = 'integer';
     $rules['carport_size'] = 'integer';
     $rules['rooms'] = 'required';
     $rules['bathrooms'] = 'required';
     $rules['maid_rooms'] = 'integer';
     $rules['maid_bathrooms'] = 'integer';
     $rules['furnishing'] = 'required|in:' . $propertyFurnishingAllowedValues;
     $rules['phone_lines'] = 'integer';
     $rules['electricity'] = 'integer';
     $rules['orientation'] = 'in:' . $orientationAllowedValues;
     $rules['for_sell'] = 'required|in:0,1';
     $rules['sell_price'] = 'required_if:for_sell,1';
     $rules['sell_viewing_schedule'] = 'required_if:for_sell,1';
     foreach ($this->input('sell_viewing_schedule', []) as $idx => $sellViewingSchedule) {
         $rules['sell_viewing_schedule.' . $idx] = 'in:' . $viewingSchedulesAllowedValues;
     }
     $rules['for_rent'] = 'required|in:0,1';
     $rules['rent_price'] = 'required_if:for_rent,1';
     $rules['rent_price_type'] = 'required_if:for_rent,1|in:' . $rentPriceTypeAllowedValues;
     $rules['rent_viewing_schedule'] = 'required_if:for_rent,1';
     foreach ($this->input('rent_viewing_schedule', []) as $idx => $rentViewingSchedule) {
         $rules['rent_viewing_schedule.' . $idx] = 'in:' . $viewingSchedulesAllowedValues;
     }
     $certificateAllowedValues = implode(',', array_keys(Property::getCertificateLabel()));
     $rules['land_size'] = 'numeric|min:1';
     $rules['land_dimension.length'] = 'numeric|required_with:land_dimension.width';
     $rules['land_dimension.width'] = 'numeric|required_with:land_dimension.length';
     if ($propertyType && $propertyType->slug == 'land') {
         $rules['land_size'] .= '|required';
     }
     $rules['building_size'] = 'numeric|min:1';
     $rules['building_dimension.length'] = 'numeric|required_with:building_dimension.width';
     $rules['building_dimension.width'] = 'numeric|required_with:building_dimension.length';
     if ($propertyType && $propertyType->slug != 'land') {
         $rules['building_size'] .= '|required';
     }
     $rules['floor'] = 'numeric';
     $rules['certificate'] = 'in:' . $certificateAllowedValues;
     $rules['virtual_tour_url'] = 'url';
     //$rules['description'] = 'required|min:10|max:300';
     $rules['latitude'] = 'required_if:point_map,1';
     $rules['longitude'] = 'required_if:point_map,1';
     $allowedPackages = implode(',', Package::lists('id')->toArray());
     $rules['sell_package'] = 'required_if:for_sell,1|in:' . $allowedPackages;
     if ($this->has('sell_package')) {
         $package = Package::findOrFail($this->input('sell_package'));
         $allowedFeatures = implode(',', $package->features->lists('id')->toArray());
         foreach ($this->input('features.sell', []) as $featureIdx => $feature) {
             $rules['features.sell.' . $featureIdx] = 'in:' . $allowedFeatures;
         }
     }
     $rules['rent_package'] = 'required_if:for_rent,1|in:' . $allowedPackages;
     if ($this->has('rent_package')) {
         $package = Package::findOrFail($this->input('rent_package'));
         $allowedFeatures = implode(',', $package->features->lists('id')->toArray());
         foreach ($this->input('features.rent', []) as $featureIdx => $feature) {
             $rules['features.rent.' . $featureIdx] = 'in:' . $allowedFeatures;
         }
     }
     return $rules;
 }