/**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $properties = \App\Property::with('propertyImages')->get();
     foreach ($properties as $checkProperty) {
         try {
             $results = \App\Libraries\RetsQuery::properties('Property', 'Listing', '(Matrix_Unique_ID = ' . $checkProperty['Matrix_Unique_ID'] . ')');
         } catch (Exception $e) {
             Bugsnag::notifyException($e);
         } catch (PHRETS\Exceptions\CapabilityUnavailable $e) {
             Bugsnag::notifyException($e);
         }
         foreach ($results as $property) {
             if ($property['Status'] !== 'Active') {
                 if (!empty($checkProperty->propertyImages->toArray())) {
                     $this->removeClosedImages($checkProperty->propertyImages);
                 }
                 $this->removeFromElasticSearch($property['MLSNumber']);
                 $property = \App\Property::find($checkProperty['id']);
                 if ($property) {
                     $property->delete();
                 }
             }
         }
     }
     dispatch((new \App\Jobs\RemoveUnrelatedImages())->onQueue('images'));
 }
Example #2
0
 public function test(Request $request)
 {
     $property = Property::find($request->prop);
     $property->language = $property->propertyLanguages()->where('locale', 'en')->first();
     //        $property->thumbnails = $property->
     $pdf = \PDF::loadView('pdf.property', ['property' => $property]);
     return $pdf->stream('invoice.pdf');
 }
Example #3
0
 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $this->registerPolicies($gate);
     // role: super admin, manager, super agent, agent
     // page: dashboard, properties(villa, villa rental, land), enquiry, customer, blog, page, setting
     $gate->define('property-edit', function ($user, $property_id) {
         $user = $user->get();
         $property = \App\Property::find($property_id);
         if ($user->role_id == 3 or $user->role_id == 4) {
             return $property->user_id == $user->id;
         }
         if ($user->role_id == 2) {
             return $property->user->branch_id == $user->branch_id;
         }
         if ($user->role_id == 1) {
             return true;
         }
     });
     $gate->define('enquiry-edit', function ($user, $enquiry_id) {
         $user = $user->get();
         $enquiry = \App\Enquiry::find($enquiry_id);
         if ($user->role_id == 3 or $user->role_id == 4) {
             return $enquiry->property->user_id == $user->id;
         }
         if ($user->role_id == 2) {
             return $enquiry->property->user->branch_id == $user->branch_id;
         }
         if ($user->role_id == 1) {
             return true;
         }
     });
     $gate->define('customer-edit', function ($user, $customer_id) {
         $user = $user->get();
         $customer = \App\Customer::find($customer_id);
         // if ($user->role_id == 3 OR $user->role_id == 4) return $customer->user_id == $user->id;
         // if ($user->role_id == 2) return $customer->user->branch_id == $user->branch_id;
         if ($user->role_id == 1) {
             return true;
         }
     });
     $gate->define('user-edit', function ($user, $user_id) {
         $user = $user->get();
         $account = \App\User::find($user_id);
         if ($user->role_id == 2) {
             return $account->branch_id == $user->branch_id;
         }
         if ($user->role_id == 1) {
             return true;
         }
     });
 }
Example #4
0
 public function properties(Request $request, $term = null)
 {
     //
     $categories = new \App\Term();
     $categories = $categories->where('type', 'property_category');
     if ($request->category) {
         $category_slug = $request->category;
         $category = \App\Term::where('slug', $category_slug)->where('type', 'property_category')->first();
         if ($category) {
             $categories = $categories->where(function ($q) use($category_slug, $category) {
                 $q->where('slug', $category_slug)->orWhere('parent_id', $category->id);
             });
         }
     }
     $categories = $categories->get();
     if ($request->action == 'create') {
         return view('admin.pages.property.create', compact('request', 'categories'));
     }
     if ($request->action == 'edit' && isset($request->id)) {
         if (Gate::denies('property-edit', $request->id)) {
             return redirect()->back();
         }
         $property = \App\Property::find($request->id);
         // exists document
         $exist_document = array();
         foreach ($property->documents as $key => $value) {
             $exist_document[] = strtolower($value->name);
         }
         // exists facility
         $exist_facility = array();
         foreach ($property->facilities as $key => $value) {
             $exist_facility[] = strtolower($value->name);
         }
         $thumb = $property->thumb()->first();
         $thumbnail = $thumb ? $thumb->value : 0;
         return view('admin.pages.property.edit', compact('property', 'request', 'categories', 'exist_document', 'exist_facility', 'thumbnail'));
     }
     if ($request->action == 'edit-translation' && isset($request->id)) {
         if (Gate::denies('property-edit', $request->id)) {
             return redirect()->back();
         }
         $property = \App\Property::find($request->id);
         return view('admin.pages.property.edit-translation', compact('property', 'request', 'categories'));
     }
     $request = json_encode($request->all());
     $request = json_decode($request, true);
     $api_url = route('api.properties.index', $request);
     return view('admin.pages.property.listing', compact('api_url', 'request'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param StoreAddressPostRequest $request
  * @return Response
  */
 public function store(StoreAddressPostRequest $request)
 {
     $address = new Address(array('unit' => $request->unit, 'street' => $request->street, 'postCode' => $request->postCode, 'city' => $request->city, 'state' => $request->state, 'country' => $request->country));
     switch (Session::get('AddRole')) {
         case "tenant":
             $client = Client::find(Session::get('ClientInsertedId'));
             $client->addresses()->save($address);
             Session::flash('flash_message', 'Address successfully added! ');
             return redirect()->action('ClientController@index');
             break;
         case "owner":
             $client = Client::find(Session::get('ClientInsertedId'));
             $client->addresses()->save($address);
             Session::flash('flash_message', 'Address successfully added! ');
             return redirect()->action('PropertyController@store', Session::get('ClientInsertedId'));
             break;
         case "property":
             $property = Property::find(Session::get('PropertyInsertedId'));
             $property->addresses()->save($address);
             return redirect()->action('OwnerController@index');
             break;
     }
     return redirect('home');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param Address $address
  * @return Response
  * @throws \Exception
  * @internal param int $id
  */
 public function destroy(Address $address)
 {
     $property = Property::find($address->addressable_id);
     $property->delete();
     $address->delete();
     return redirect()->back();
 }
Example #7
0
 public function propertyView($category, $slug)
 {
     $slug = explode('-', $slug);
     $id = end($slug);
     $property = Property::find($id);
     return view('pages.property-view', compact('property'));
 }
Example #8
0
 if ($validator->fails()) {
     return redirect(url('/property/edit/' . $data['property_id']))->withInput()->withErrors($validator);
 }
 $myErrorArr = array();
 $districts = District::where('name', $request->district)->get();
 if (count($districts) < 1) {
     array_push($myErrorArr, 'That district is not recognized');
 }
 $cities = City::where('name', $request->city)->get();
 if (count($cities) < 1) {
     array_push($myErrorArr, 'That city is not recognized.');
 }
 if (count($myErrorArr) > 0) {
     return redirect(url('/property/add'))->withInput()->withErrors($myErrorArr);
 }
 $property = Property::find($data['property_id']);
 $property->title = $request->title;
 $property->address = $request->address;
 $property->district_id = $districts[0]->id;
 $property->city_id = $cities[0]->id;
 $property->type = $request->type;
 $property->price_per_night = $request->price_per_night;
 $property->max_occupancy = $request->max_occupancy;
 $property->description = $request->description;
 $property->save();
 $features = PropertyFeatures::where('property_id', $property->id)->get()[0];
 $features->property_id = $property->id;
 $features->kitchen = on2true($request->get('kitchen', false));
 $features->internet = on2true($request->get('internet', false));
 $features->tv = on2true($request->get('tv', false));
 $features->essentials = on2true($request->get('essentials', false));
 public function show($id)
 {
     $announcement = Property::find($id);
     $time = $announcement->creation_time();
     $sameAnnon = Property::where('price', '=', $announcement->price)->where('area_id', '=', $announcement->area->first()->id)->take(3)->get();
     //  dd($announcement);
     if (is_null($announcement)) {
         abort(404);
     }
     return view('announcements.show', compact('announcement', 'time', 'sameAnnon'));
 }
Example #10
0
 public function delete($id)
 {
     //
     $property = Property::find($id);
     $property->delete();
     return response()->json(array('status' => 200, 'monolog' => array('title' => 'delete success', 'message' => 'object has been deleted'), 'id' => $id));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $property = Property::find($id);
     $property->delete();
     // $property->softDeletes();
     // return redirect()->back();
     return response()->json(array('status' => 200, 'monolog' => array('title' => 'delete success', 'message' => 'Property has been deleted'), 'id' => $id));
 }
Example #12
0
 public function show($id)
 {
     $property = Property::find($id);
     return view('properties.show', compact('property'));
 }
 public function getBid($property_id)
 {
     $property = Property::find($property_id);
     return response()->view('property.view', ['property' => $property]);
 }
 public function postAddcolumns(Request $request)
 {
     $category = session('category');
     $propertyIDs = $request->except('_token');
     $validator = $this->validatorForProperties($propertyIDs);
     if ($validator->fails()) {
         $request->session()->flash('category', $category);
         return redirect()->back()->withErrors($validator->messages())->withInput();
     }
     $category->save();
     Schema::create($category->table_name, function (Blueprint $table) use($category, $request, $propertyIDs) {
         $table->increments('id');
         $table->integer('product_id')->unsigned();
         foreach ($propertyIDs as $propertyID) {
             $property = Property::find($propertyID);
             switch ($property->type) {
                 case 0:
                     $table->integer($property->real_name);
                     break;
                 case 1:
                     $table->string($property->real_name);
                     break;
                 case 2:
                     $table->text($property->real_name);
                     break;
                 case 3:
                     $table->date($property->real_name);
             }
         }
         $table->timestamps();
     });
     Schema::table($category->table_name, function (Blueprint $table) {
         $table->foreign('product_id')->references('id')->on('products')->onUpdate('cascade')->onDelete('cascade');
     });
     $msg = "Категория \"" . $category->name . "\" добавлена.";
     return redirect('admin/category')->with('msg', $msg);
 }