/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $allusers = User::all();
     $url = "https://randomapi.com/api/?key=" . env('RANDOMAPI_API_KEY') . "&id=6tnf0qn&results=50";
     $json = file_get_contents($url);
     $json_data = json_decode($json, true);
     $types = ['private_room', 'shared_room', 'entire_place'];
     foreach ($json_data['results'] as $result) {
         $result = $result['object'];
         $property = new Property();
         $property->title = $result['title'];
         $oneuser = $allusers[rand(0, count($allusers) - 1)];
         $property->owner_id = $oneuser->id;
         $property->address = explode(" | ", $result['address'])[2];
         $all_cities = City::all();
         $property->city_id = $all_cities[rand(0, count($all_cities) - 1)]->id;
         $valid_districts = District::where('city_id', $property->city_id)->get();
         $property->district_id = $valid_districts[rand(0, count($valid_districts) - 1)]->id;
         $property->type = $types[array_rand($types)];
         $property->price_per_night = rand(20, 1333);
         $property->max_occupancy = rand(1, 6);
         $property->description = 'A charming ' . $result['title'];
         $property->save();
         $features = new PropertyFeatures();
         $features->property_id = $property->id;
         $features->kitchen = rand(0, 1) == 1;
         $features->internet = rand(0, 1) == 1;
         $features->tv = rand(0, 1) == 1;
         $features->essentials = rand(0, 1) == 1;
         $features->shampoo = rand(0, 1) == 1;
         $features->heating = rand(0, 1) == 1;
         $features->air_conditioning = rand(0, 1) == 1;
         $features->washer = rand(0, 1) == 1;
         $features->dryer = rand(0, 1) == 1;
         $features->free_parking_on_premises = rand(0, 1) == 1;
         $features->wireless_internet = rand(0, 1) == 1;
         $features->cable_tv = rand(0, 1) == 1;
         $features->breakfast = rand(0, 1) == 1;
         $features->pets_allowed = rand(0, 1) == 1;
         $features->family_kid_friendly = rand(0, 1) == 1;
         $features->suitable_for_events = rand(0, 1) == 1;
         $features->smoking_allowed = rand(0, 1) == 1;
         $features->wheelchair_accessible = rand(0, 1) == 1;
         $features->elevator_in_building = rand(0, 1) == 1;
         $features->indoor_fireplace = rand(0, 1) == 1;
         $features->buzzer_wireless_intercom = rand(0, 1) == 1;
         $features->doorman = rand(0, 1) == 1;
         $features->pool = rand(0, 1) == 1;
         $features->hot_tub = rand(0, 1) == 1;
         $features->gym = rand(0, 1) == 1;
         $features->feature_24_hour_check_in = rand(0, 1) == 1;
         $features->hangers = rand(0, 1) == 1;
         $features->iron = rand(0, 1) == 1;
         $features->hair_dryer = rand(0, 1) == 1;
         $features->laptop_friendly_workspace = rand(0, 1) == 1;
         $features->save();
     }
 }
Exemplo n.º 2
0
 /**
  * Get the properties for this note.
  */
 public function properties()
 {
     $foreignKey = 'strKey';
     $localKey = 'strKey';
     $instance = new Property();
     $instance->setConnection($this->getConnectionName());
     return new HasMany($instance->newQuery(), $this, $foreignKey, $localKey);
     //return $this->HasOne('App\Property', 'strKey', 'strKey');
 }
 public function testNotificationDelete()
 {
     $admin = User::find(1);
     $property = new Property();
     $property->address_line_1 = "123 Fake Street";
     $property->address_line_2 = "Number 3";
     $property->city = "Test City";
     $property->county = "Test County";
     $property->postcode = "FR123KE";
     $property->save();
     $savedProperty = Property::where('postcode', '=', 'FR123KE')->first();
     $this->actingAs($admin)->withSession(['foo' => 'bar'])->visit($this->modelUrl . (string) $savedProperty->id)->press('Delete')->seePageIs($this->modelUrl);
 }
 public function postAdd(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator->messages())->withInput();
     }
     $property = new Property();
     $property->name = $request->input('name');
     $property->real_name = Slug::make($request->input('name'));
     $property->type = $request->input('type');
     $property->save();
     $msg = "Характеристика \"" . $property->name . "\" добавлена.";
     return Redirect::to('admin/property')->with('msg', $msg);
 }
 /**
  * Process datatables ajax request.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function anyData()
 {
     $database = Auth::user()->getDatabase();
     $property = new Property();
     $property->changeConnection($database);
     $d = Property::on($database)->with('note', 'owner')->select('*');
     //$d = Property::on($database)
     //    ->leftjoin('owners', 'owners.strIDNumber', '=', 'properties.strIdentity')
     //    ->leftjoin('notes', 'notes.strKey', '=', 'properties.strKey')
     //    ->select('*')
     //    ->get();
     //dd($d);
     //  dd(Datatables::of($d)->make(true));
     //$d->load('owner', 'note');
     return Datatables::of($d)->make(true);
 }
 /**
  * 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'));
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('client', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return Client::findOrFail($id);
     });
     $router->bind('bank', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return BankDetail::findOrFail($id);
     });
     $router->bind('address', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return Address::findOrFail($id);
     });
     $router->bind('property', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return Property::findOrFail($id);
     });
     $router->bind('agreement', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return RentalAgreement::findOrFail($id);
     });
     //
 }
Exemplo n.º 8
0
 public function destroy($id)
 {
     $property = Property::findOrFail($id);
     $contract = Contract::where('property_id', '=', $id)->delete();
     $property->delete();
     return redirect('properties');
 }
Exemplo n.º 9
0
 public function create()
 {
     $rented = Contract::select('property_id')->get();
     $renters = Renter::select('id', 'first_name', 'last_name')->get()->toArray();
     $properties = Property::select('id', 'address')->whereNotIn('id', $rented)->get()->toArray();
     return view('contracts.create', compact('rented', 'renters', 'properties'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     return Property::with('user', 'landlord', 'tenants')->get();
     // return Property::with('landlord')->get();
     // return Property::all();
 }
Exemplo n.º 11
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit(Apartment $apartment)
 {
     //
     $properties = Property::lists('abbreviation', 'id');
     //$apartment = Apartment::with('property')->find($id);
     return view('apartments.edit', ['title' => 'Edit Apartment', 'properties' => $properties, 'apartment' => $apartment]);
 }
Exemplo n.º 12
0
 /**
  * Handle the event.
  *
  * @param  ClaimCreate  $event
  * @return void
  */
 public function handle(ClaimCreate $event)
 {
     $claim = $event->claim;
     $properties = \App\Property::showPropertyValue($claim);
     $send = 1;
     $rType = $event->claim->typeR();
     if (!empty($rType)) {
         $send = $rType->send_mail;
     }
     if ($send == 1) {
         \Mail::send('emails.claimcreate', compact('claim', 'properties'), function ($message) use($event) {
             $emails = [];
             $emails[] = $event->claim->project->client->email;
             if (!empty($event->claim->project->client->send_email)) {
                 $emailsSplit = explode(",", $event->claim->project->client->send_email);
                 foreach ($emailsSplit as $item) {
                     $emails[] = trim($item);
                 }
             }
             Log::alert('Отправка письма ' . $event->claim->id . ", email:" . $event->claim->project->client->send_email . ", " . $event->claim->project->client->email);
             $res = $message->to($emails, 'Callcenter №1')->subject('Круглосуточный call-центр №1');
             Log::info(json_encode($res));
         });
     }
     if (!empty($event->destinations)) {
         \Mail::send('emails.claimcreate', compact('claim', 'properties'), function ($message) use($event) {
             $message->to($event->destinations, 'Callcenter №1')->subject('Круглосуточный call-центр №1');
         });
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $contacts = Contact::orderBy('id', 'desc')->paginate(10);
     $option = Option::findOrFail(1);
     $featured_properties = Property::where('Heat_inc', '=', 'Yes')->get();
     return view('home', ['contacts' => $contacts, 'option' => $option, 'featured_properties' => $featured_properties]);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     //
     $key = Key::findOrFail($id);
     $contractors = User::all()->sortBy('full_name');
     $properties = Property::all();
     return View('keys.edit', compact(['key', 'contractors', 'properties']));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     $contractor = User::with('keys')->findOrFail($id);
     $keys = Key::all();
     $properties = Property::all();
     return View('contractors.show', compact(['contractor', 'keys', 'properties']));
 }
Exemplo n.º 16
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');
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $properties = \App\Property::all();
     foreach ($properties as $property) {
         $property->delete();
     }
     dispatch((new RemoveUnrelatedImages())->onQueue('killImage'));
 }
 public function setMainImage($mls)
 {
     $mainImage = null;
     $property = \App\Property::with('propertyImages')->where('Matrix_Unique_ID', '=', $mls)->first();
     if (!$property->propertyImages->isEmpty()) {
         $mainImage = $property->propertyImages[0]->dataUri;
     }
     return $mainImage;
 }
Exemplo n.º 19
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $projects = [];
     foreach (Claim::month()->get() as $claim) {
         $projects[$claim->project_id][] = $claim;
     }
     foreach ($projects as $key => $claims) {
         $project = Project::find($key);
         $styleTd = 'style="border:1px solid #000;"';
         $table = '<table cellpadding="2" cellspacing="0" style="margin: 0;  width:100%;">';
         $table .= "<tr><td {$styleTd}>id</td><td {$styleTd}>Дата</td><td {$styleTd}>Клиент</td><td {$styleTd}>Контактный телефон</td><td {$styleTd}>Описание</td><td {$styleTd}>Дата обратного звонка</td><td {$styleTd}>Статус</td>";
         $propertiesPR = Property::where('model_initiator', '=', 'project')->where('link_id', '=', $key)->orderBy('sort')->get();
         foreach ($propertiesPR as $property) {
             $table .= "<td {$styleTd}>" . $property->title . "</td>";
         }
         $table .= "</tr>";
         foreach ($claims as $claim) {
             $table .= "<tr>";
             $table .= "<td {$styleTd}>{$claim->id}</td>";
             $table .= "<td {$styleTd}>" . $claim->created_at->format('d.m.Y H:i') . "</td>";
             $table .= "<td {$styleTd}>{$claim->name}</td>";
             $table .= "<td {$styleTd}>{$claim->phone}</td>";
             $table .= "<td {$styleTd}>{$claim->text}</td>";
             $table .= "<td {$styleTd}>{$claim->backcall_at}</td>";
             $table .= "<td {$styleTd}>" . $claim->statusT->title . "</td>";
             $propertiesByTitle = [];
             $properties = \App\Property::showPropertyValue($claim);
             foreach ($properties as $prop) {
                 $propertiesByTitle[$prop["title"]] = $prop["value"];
             }
             foreach ($propertiesPR as $property) {
                 if (!empty($propertiesByTitle[$property->title])) {
                     $table .= "<td {$styleTd}>" . $propertiesByTitle[$property->title] . "</td>";
                 } else {
                     $table .= "<td {$styleTd}></td>";
                 }
             }
             $table .= "</tr>";
         }
         $table .= "</table>";
         $title = "Отчет за месяц: " . $project->title;
         \Mail::send('emails.reports', compact('table', 'title'), function ($message) use($project) {
             $emails = ['*****@*****.**', '*****@*****.**'];
             /*
             $emails[] = $project->client->email;
             if(!empty($project->client->send_email)){
                 $emailsSplit  = explode(",",$project->client->send_email);
                 foreach($emailsSplit as $item)
                 {
                     $emails[] = trim($item);
                 }
             }
             */
             $message->to($emails, 'Callcenter №1')->subject('Круглосуточный call-центр №1');
         });
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     if (rand(0, 1) == 1) {
         $url = "https://pixabay.com/api/?key=" . env('PIXABAY_API_KEY') . "&image_type=photo&category=buildings&safesearch=true&min_width=500";
         $json = file_get_contents($url);
         $json_data = json_decode($json, true);
         $pixa_json = $json_data['hits'];
         foreach ($pixa_json as $image) {
             $pictureUploadResult = \Cloudinary\Uploader::upload($image['webformatURL']);
             if ($pictureUploadResult == null) {
                 echo "Error uploading picture";
                 continue;
             }
             $picture = new Picture();
             $picture->description = "";
             $picture->url = $pictureUploadResult['secure_url'];
             $picture->cloudinary_public_id = $pictureUploadResult['public_id'];
             $picture->save();
             $junction = new PropertyPictureBridge();
             $all_properties = Property::all();
             $one_property = $all_properties[rand(0, count($all_properties) - 1)];
             $junction->property_id = $one_property->id;
             $junction->picture_id = $picture->id;
             $junction->save();
         }
     } else {
         $api_key = env('FLICKR_API_KEY');
         $query = 'new york city apartment';
         $url = "https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=" . $api_key . "&tags=" . urlencode($query) . "&safe_search=1&per_page=20&format=json";
         $json_data = file_get_contents($url);
         $json_data = substr($json_data, 14);
         $json_data = substr($json_data, 0, strlen($json_data) - 1);
         $json_data = json_decode($json_data, true);
         foreach ($json_data['photos']['photo'] as $photo) {
             $farm = $photo['farm'];
             $server = $photo['server'];
             $src = 'http://farm' . $farm . '.static.flickr.com/' . $server . '/' . $photo['id'] . '_' . $photo['secret'] . '_z.jpg';
             $pictureUploadResult = \Cloudinary\Uploader::upload($src);
             if ($pictureUploadResult == null) {
                 echo "Error uploading picture";
                 continue;
             }
             $picture = new Picture();
             $picture->description = "";
             $picture->url = $pictureUploadResult['secure_url'];
             $picture->cloudinary_public_id = $pictureUploadResult['public_id'];
             $picture->save();
             $junction = new PropertyPictureBridge();
             $all_properties = Property::all();
             $one_property = $all_properties[rand(0, count($all_properties) - 1)];
             $junction->property_id = $one_property->id;
             $junction->picture_id = $picture->id;
             $junction->save();
         }
     }
 }
Exemplo n.º 21
0
 public function getAdminPanel()
 {
     $pageName = 'Dashboard';
     $users = Sentry::findAllUsers();
     $newUsers = new Collection($users);
     $userNumber = $newUsers->count();
     $propertyNumber = Property::all()->count();
     $soldPropertyNumber = Property::where('state', '=', 'sold')->count();
     $newsNumber = News::all()->count();
     return view('admin.adminIndex')->with(compact('pageName', 'userNumber', 'propertyNumber', 'soldPropertyNumber', 'newsNumber'));
 }
 public function location(Request $request)
 {
     if ($request->isMethod('post')) {
         $data = array_merge(Session::get('property'), Input::all());
         $data['user_id'] = Auth::user()->id;
         unset($data['_token']);
         $propertyId = Property::insert($data);
         return Redirect::to('property/facilities/' . $propertyId . "/create");
     }
     return view('property.location');
 }
Exemplo n.º 23
0
 public function rolledit($id)
 {
     try {
         // set database
         $database = Auth::user()->getDatabase();
         //change database
         $property = new Property();
         $property->changeConnection($database);
         // search on street name
         $query = Property::on($database)->where('strOwners', $id)->orderby('strOwners', 'ASC')->get();
         $properties = Property::on($database)->where('strOwners', $id)->orderby('strOwners', 'ASC')->simplePaginate(1);
         // get relationship data
         $properties->load('owner', 'note');
         // get total records as simplepagination does not do this
         $count = $query->count();
         $search = $id;
         $streets = Street::on($database)->orderBy('strStreetName', 'ASC')->lists('strStreetName', 'strStreetName');
     } catch (exception $e) {
         dd($e->getMessage());
     }
     return view('property', compact('properties', 'count', 'search', 'streets'));
 }
Exemplo n.º 24
0
 private function groupedSelect()
 {
     if (!auth()->user()->hasRole('admin')) {
         $properties = auth()->user()->properties()->where('status', 1);
     } else {
         $properties = Property::where('status', 1);
     }
     $select_optgroup_arr_properties = [];
     foreach ($properties->get() as $item) {
         $select_optgroup_arr_properties[$item->province][$item->id] = $item->name;
     }
     return $select_optgroup_arr_properties;
 }
Exemplo n.º 25
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;
         }
     });
 }
Exemplo n.º 26
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'));
 }
Exemplo n.º 27
0
 public function getClaims(Request $request)
 {
     if (!$request->has('key')) {
         abort('500', 'Key not found');
     }
     $user = User::where('apikey', '=', $request->input('key'))->first();
     if (is_null($user)) {
         abort('500', 'User with this key not found');
     }
     $projects = Project::where('client_id', '=', $user->id)->get();
     $claims = [];
     foreach ($projects as $project) {
         $claimCollection = Claim::where('project_id', '=', $project->id);
         if ($request->has('dts')) {
             $dtsObj = new \DateTime($request->input('dts'));
             if (get_class($dtsObj) !== "DateTime") {
                 abor(500, 'Wrong date format');
             }
             $claimCollection = $claimCollection->where('created_at', '>=', $dtsObj->format('Y-m-d H:i:s'));
         }
         if ($request->has('dte')) {
             $dteObj = new \DateTime($request->input('dte'));
             if (get_class($dteObj) !== "DateTime") {
                 abor(500, 'Wrong date format');
             }
             $claimCollection = $claimCollection->where('created_at', '<=', $dteObj->format('Y-m-d H:i:s'));
         }
         $claimCollection = $claimCollection->orderBy('created_at', "DESC")->get();
         foreach ($claimCollection as $claim) {
             $claimEl["id"] = $claim->id;
             $claimEl["project"] = $project->title;
             $claimEl["title"] = $claim->title;
             $claimEl["text"] = $claim->text;
             $claimEl["note"] = $claim->note;
             $claimEl["phone"] = $claim->phone;
             $claimEl["backcall_at"] = $claim->backcall_at;
             $claimEl["created_at"] = $claim->created_at->format('Y-m-d H:i:s');
             $claimEl["statusT"] = $claim->statusT->title;
             $claimEl['properties'] = [];
             foreach (\App\Property::showPropertyValue($claim) as $property) {
                 $claimEl['properties'][$property["code"]] = $property['value'];
             }
             $claims[] = $claimEl;
         }
     }
     $response = new KodiResponse();
     return $response->createResponse($claims, 200);
 }
Exemplo n.º 28
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // get user id
     // connect to farmbook and get default database
     $database = Auth::user()->getDatabase();
     //change database dynamically to user set database
     $street = new Street();
     $street->changeConnection($database);
     $streets = Street::on($database)->orderBy('strStreetName', 'ASC')->lists('strStreetName', 'id');
     $complexes = Complex::on($database)->orderBy('strComplexName', 'ASC')->lists('strComplexName', 'id');
     // $owners = Owner::on($database )->orderBy('NAME','DESC')->lists('NAME', 'id');
     $owners = Property::on($database)->orderBy('strOwners', 'DESC')->groupBy('strOwners')->lists('strOwners', 'id');
     $properties = Property::on($database)->orderBy('strKey', 'ASC')->lists('strkey', 'id');
     $erfs = Note::on($database)->orderBy('numErf', 'ASC')->lists('numErf', 'id');
     return view('search', compact('streets', 'complexes', 'owners', 'properties', 'erfs'));
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     // Load Undeposited Payments to Nav Bar
     view()->composer('inc.header', function ($view) {
         $view->with('undepositedfunds', \App\Payment::whereRaw('bank_deposits_id IS NULL')->get()->sum('amount'));
         $properties = \App\Property::all();
         $rents_due = 0;
         $deposits_due = 0;
         foreach ($properties as $p) {
             $rents_due += $p->rentBalance();
             $deposits_due += $p->depositBalance();
         }
         $view->with('rents_due', $rents_due);
         $view->with('deposits_due', $deposits_due);
         $view->with('properties', $properties);
     });
 }
Exemplo n.º 30
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $num_bookings = 50;
     $all_properties = \App\Property::all();
     $users = \App\User::all();
     $statuses = array('requested', 'confirmed', 'rejected');
     for ($i = 0; $i < $num_bookings; $i++) {
         $one_property = $all_properties[mt_rand(0, count($all_properties) - 1)];
         $one_customer = null;
         $customer_id_ok = false;
         while (!$customer_id_ok) {
             $one_customer = $users[mt_rand(0, count($users) - 1)];
             if ($one_customer->id != $one_property->owner_id) {
                 $customer_id_ok = true;
             }
         }
         $one_status = $statuses[mt_rand(0, count($statuses) - 1)];
         $booking_ok = false;
         $start = null;
         $end = null;
         while (!$booking_ok) {
             $start = $this->randomDate(date('2016-01-01'), "2016-04-30");
             $start_time_plus_one_day = strtotime($start);
             $start_time_plus_one_day = strtotime("+1 day", $start_time_plus_one_day);
             $start_time_plus_seven_days = strtotime($start);
             $start_time_plus_seven_days = strtotime("+7 day", $start_time_plus_seven_days);
             $end = $this->randomDate(date('Y-m-d', $start_time_plus_one_day), date('Y-m-d', $start_time_plus_seven_days));
             $select_statement = 'select * from bookings WHERE ' . "'" . $start . "'" . ' <= bookings.end AND ' . "'" . $end . "'" . ' >= start AND bookings.status = ' . "'" . 'confirmed' . "'" . 'AND bookings.property_id = ' . $one_property->id;
             $overlapping_bookings = DB::select($select_statement);
             if (count($overlapping_bookings) == 0) {
                 $booking_ok = true;
             }
         }
         $booking = new \App\Booking();
         $booking->customer_id = $one_customer->id;
         $booking->property_id = $one_property->id;
         $booking->start = $start;
         $booking->end = $end;
         $booking->status = $one_status;
         $booking->save();
     }
 }