/**
  * 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]);
 }
Esempio n. 2
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');
         });
     }
 }
Esempio n. 3
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 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);
 }
Esempio n. 5
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;
 }
Esempio n. 6
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $model = \Request::get('model');
     if (empty($model)) {
         return abort('404', \Lang::get('property.existModel'));
     }
     $link_id = \Request::get('link_id');
     if (empty($link_id)) {
         return abort('404', \Lang::get('property.existLinkElement'));
     }
     $propties = Property::where('model_initiator', '=', $model)->where('link_id', '=', $link_id)->orderBy('sort')->get();
     $proptyList = [];
     foreach ($propties as $property) {
         $property->type = $this->propertiesType[$property->type];
         array_push($proptyList, $property);
     }
     return Response::json($proptyList);
 }
 public function getProducts(Request $request, $subcategory = null)
 {
     if ($subcategory == null) {
         if (null != $request->input('id')) {
             $product = Product::where('id', $request->input('id'))->first();
             if ($product == null) {
                 return redirect('products');
             }
             $category = Category::where('id', $product->category_id)->first();
             $productWIthProperties = DB::table('products')->join($category->table_name, 'products.id', '=', $category->table_name . '.product_id')->select('products.*', $category->table_name . '.*')->where('products.id', '=', $request->input('id'))->first();
             $columns = Schema::getColumnListing($category->table_name);
             // здесь удаляются имена ненужных столбцов:
             // id, product_id, created_at, updated_at
             array_splice($columns, 0, 2);
             array_splice($columns, count($columns) - 2, 2);
             $properties = [];
             foreach ($columns as $column) {
                 $property = Property::where('real_name', $column)->first();
                 array_push($properties, $property);
             }
             return view('home.product')->with(['product' => $productWIthProperties, 'properties' => $properties]);
         }
         $categories = Category::where('parent_id', null)->where('type', 0)->paginate(6);
         //->get();
         return view('home.categories')->with(['categories' => $categories, 'pageTitle' => 'Наша продукция']);
     } else {
         $parent = Category::where('table_name', $subcategory)->first();
         if ($parent->final == 0) {
             $categories = Category::where('parent_id', $parent->id)->paginate(6);
             //->get();
             return view('home.categories')->with(['categories' => $categories, 'pageTitle' => $parent->name]);
         } else {
             $products = Product::where('category_id', $parent->id)->paginate(6);
             //->get();
             return view('home.products')->with(['products' => $products, 'pageTitle' => $parent->name]);
         }
     }
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $images = [];
     try {
         $createdProperty = \App\Property::where('MLSNumber', '=', $this->property['MLSNumber'])->with('propertyImages')->first();
     } catch (Exception $e) {
         Bugsnag::notifyException($e);
     }
     switch (true) {
         case !is_null($createdProperty):
             $createProperty = $createdProperty->update($this->property);
             break;
         default:
             $createProperty = \App\Property::create($this->property);
             $listingAgent = dispatch((new CreateListingAgent($createProperty, $this->property))->onQueue('additionalInformation'));
             $community = dispatch((new CreateListingCommunity($createProperty, $this->property))->onQueue('additionalInformation'));
             if ($this->property['PhotoCount'] > 0) {
                 $images = dispatch((new GetPropertyImages($createProperty, $this->property['Matrix_Unique_ID']))->onQueue('images'));
             }
             $createdAt = $this->setCreatedAt($createProperty->toArray());
             dispatch((new IndexProperty($this->property, $createdAt))->onQueue('indexProperty'));
             break;
     }
 }
Esempio n. 9
0
 /**
  * Display homepage
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return view('home.index', ["slides" => Slide::all(), "brands" => Property::where("is_brand", true)->orderBy('created_at', 'DESC')->take(7)->get(), "latests" => Property::orderBy("created_at", "DESC")->take(9)->get()]);
 }
 public function showSingleProperties(Request $request, $listingId)
 {
     $property = \App\Property::where('MLSNumber', '=', $listingId)->with('propertyImages')->first();
     if (is_null($property)) {
         return redirect()->route('properties')->with('error_message', 'Property is no longer available');
     }
     $amentities = $this->getAmentities($property);
     $geocode = new Geocode();
     $address = $property['StreetNumber'] . ' ' . $property['StreetName'] . ' ' . $property['City'] . ' ' . $property['StateOrProvince'] . ' ' . $property['PostalCode'];
     $geoLocation = $geocode->getCoordinates($address);
     switch (true) {
         case !is_null($request->cookie('propertyViews')):
             if (!\Auth::check()) {
                 $this->views = $this->views + (int) $request->cookie('propertyViews');
                 if ($this->views > 0) {
                     $response = new \Illuminate\Http\Response(view('pages.propertyDetailSubscribe')->with(['property' => $property, 'communities' => $this->communities, 'amentities' => $amentities, 'geoLocation' => isset($geoLocation['geometry']) ? $geoLocation['geometry']['location'] : []]));
                 }
                 $response->withCookie(cookie()->forever('propertyViews', $this->views + 1));
             } else {
                 $response = new \Illuminate\Http\Response(view('pages.propertyDetail')->with(['property' => $property, 'communities' => $this->communities, 'amentities' => $amentities, 'geoLocation' => isset($geoLocation['geometry']) ? $geoLocation['geometry']['location'] : [], 'recent' => $this->recent]));
                 $response->withCookie(cookie()->forget('propertyViews'));
             }
             break;
         default:
             $response = new \Illuminate\Http\Response(view('pages.propertyDetail')->with(['property' => $property, 'communities' => $this->communities, 'amentities' => $amentities, 'geoLocation' => isset($geoLocation['geometry']) ? $geoLocation['geometry']['location'] : [], 'recent' => $this->recent]));
             $response->withCookie(cookie()->forever('propertyViews', $this->views + 1));
             break;
     }
     return $response;
 }
 public function propertyCustomer()
 {
     $search = \Input::get('q');
     // AGENT
     if ($this->admin->role_id == 3) {
         if ($search) {
             $properties = \App\Property::select('Properties.*')->join('PropertyLanguages', 'PropertyLanguages.property_id', '=', 'Properties.id')->where('PropertyLanguages.locale', $this->lang)->where('PropertyLanguages.title', 'like', $search . '%')->where('Properties.user_id', $this->admin->id)->where('status', -2)->orderBy('Properties.created_at', 'desc')->paginate($this->limit);
         } else {
             $properties = \App\Property::where('user_id', $this->admin->id)->where('status', -2)->orderBy('created_at', 'desc')->paginate($this->limit);
         }
         // SUPER ADMIN
     } else {
         if ($search) {
             $properties = \App\Property::select('Properties.*')->join('PropertyLanguages', 'PropertyLanguages.property_id', '=', 'Properties.id')->where('PropertyLanguages.locale', $this->lang)->where('PropertyLanguages.title', 'like', $search . '%')->where('status', -2)->orderBy('Properties.created_at', 'desc')->paginate($this->limit);
         } else {
             $properties = \App\Property::orderBy('created_at', 'desc')->where('status', -2)->paginate($this->limit);
         }
     }
     $categories = \App\Category::orderBy('order', 'asc')->where('parent_id', 0)->get();
     return view('admin.pages.request-properties', compact('properties', 'categories'));
 }
Esempio n. 12
0
     $num_stars = $num_stars[0]->avg;
     $num_stars = floor($num_stars * 2) / 2;
 } else {
     $num_stars = null;
 }
 $property->num_stars = $num_stars;
 /* Get all the comments on this property */
 $comments = Comment::where('property_id', $property->id)->get();
 foreach ($comments as $comment) {
     $comment->author_pic = get_thumbnail_from_user_id($comment->user_id);
     $comment->author = User::find($comment->user_id);
     $reply = \App\Reply::where('reply_to_id', $comment->id)->get();
     $comment->reply = $reply;
 }
 /* Get all the comments for this user */
 $all_owner_properties = Property::where('owner_id', $owner->id)->get();
 $all_owner_comments = array();
 foreach ($all_owner_properties as $owner_property) {
     $property_comments = Comment::where('property_id', $owner_property->id)->get();
     foreach ($property_comments as $owner_property_comment) {
         array_push($all_owner_comments, $owner_property_comment);
     }
 }
 $owner->number_of_reviews = count($all_owner_comments);
 /* Get this district */
 $district = District::find($property->district_id);
 /* Get the POIs for this district */
 $pois = \App\PointOfInterest::where('district_id', $district->id)->get();
 /* Store the POIs with the district */
 $district->pois = $pois;
 /* Get the city for lat/long purposes */
Esempio n. 13
0
 /**
  * Display a listing of the properties in brand.
  *
  * @return \Illuminate\Http\Response
  */
 public function brand()
 {
     return view('property.brand', ["properties" => Property::where("is_brand", true)->orderBy('created_at', 'DESC')->paginate(20)]);
 }
Esempio n. 14
0
 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'));
 }
Esempio n. 15
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $test = \App\Property::where(['property_id' => $id, 'status' => '1'])->first();
     return $test;
 }
 public function getSearch(Request $request)
 {
     $keyword = $request->keyword;
     $min = $request->min;
     $max = $request->max;
     $properties = array();
     if ($max && $min) {
         $properties = Property::where('address', 'LIKE', '%' . $keyword . '%')->whereBetween('min_property_amount', array($min, $max))->get();
     } else {
         if ($max) {
             $properties = Property::where('address', 'LIKE', '%' . $keyword . '%')->where('min_property_amount', '<=', $max)->get();
         } else {
             if ($min) {
                 $properties = Property::where('address', 'LIKE', '%' . $keyword . '%')->where('min_property_amount', '>=', $min)->get();
             } else {
                 if ($keyword) {
                     $properties = Property::where('address', 'LIKE', '%' . $keyword . '%')->get();
                 }
             }
         }
     }
     return response()->view('property.search', ['properties' => $properties]);
 }
 public function propertySearch($slug)
 {
     $find = \Input::get('find');
     $category = \Input::get('category');
     $price = \Input::get('price');
     if ($find != 'all') {
         $find = explode('-', $find);
         $type = end($find);
         $srctype = $find[3];
         $titles = $srctype == '1' || $srctype == '2' ? $find[0] . ' ' . $find[1] . ' $' . $find[2] : $find[0] . ' ' . $find[1] . ' ' . $find[2];
     } else {
         $type = 'Properties';
         $srctype = '';
         $titles = 'All';
     }
     $property = Property::where('id', '<', '20')->paginate(10);
     return view('pages.search-property', compact('type', 'titles', 'srctype', 'property'));
 }
Esempio n. 18
0
 public function searchResults(Request $request)
 {
     $result = null;
     // OR search
     if ($request->architectures) {
         $result = Property::whereHas('architectures', function ($query) use($request) {
             $query->whereIn('id', array_keys($request->architectures));
         });
     }
     // AND search (from http://laravel.io/forum/04-07-2014-search-post-by-many-tags)
     if ($request->exteriorFeatures) {
         if (!$result) {
             $result = Property::where('id', '>', 1);
         }
         $result = $result->whereHas('exteriorFeatures', function ($query) use($request) {
             $query->whereIn('id', array_keys($request->exteriorFeatures));
         }, count(array_keys($request->exteriorFeatures)));
     }
     if ($result) {
         $properties = $result->get();
     }
     return view('properties.searchResults', compact('properties'));
 }
 public function getIndex(Request $request)
 {
     $keyword = $request->keyword;
     $properties = Property::where('address', 'LIKE', '%' . $keyword . '%')->get();
     return response()->view('search', ['properties' => $properties, 'keyword' => $keyword]);
 }
 public function getEdit($id)
 {
     $product = Product::where('id', $id)->first();
     if ($product == null) {
         $msg = "Продукта с id=" . $id . " не существует.";
         return redirect('admin/product')->with('msg', $msg);
     }
     $category = Category::where('id', $product->category_id)->first();
     $query = DB::table('products')->join($category->table_name, 'products.id', '=', $category->table_name . '.product_id')->select('products.*');
     $columns = Schema::getColumnListing($category->table_name);
     // здесь удаляются имена ненужных столбцов:
     // id, product_id, created_at, updated_at
     array_splice($columns, 0, 2);
     array_splice($columns, count($columns) - 2, 2);
     $properties = [];
     foreach ($columns as $column) {
         $property = Property::where('real_name', $column)->first();
         array_push($properties, $property);
     }
     foreach ($columns as $column) {
         $query->addSelect($category->table_name . '.' . $column);
     }
     $productWIthProperties = $query->where('products.id', '=', $id)->first();
     return view('admin.product.edit')->with(['product' => $productWIthProperties, 'properties' => $properties]);
 }
Esempio n. 21
0
<?php

Route::model('property_status', 'App\\PropertyStatus');
Route::model('page', 'App\\Page');
Route::model('blog', 'App\\Blog');
Route::bind('property', function ($value, $route) {
    return \App\Property::where('slug', $value)->firstOrFail();
});
Route::get('/', ["as" => "home.index", "uses" => 'HomeController@index']);
Route::get('properties', ["as" => "property.index", "uses" => 'PropertyController@index']);
Route::get('property/{property}', ["as" => "property.show", "uses" => 'PropertyController@show']);
Route::get('property-status/{property_status}', ["as" => "property.status", "uses" => 'PropertyController@status']);
Route::get('brand', ["as" => "property.brand", "uses" => 'PropertyController@brand']);
Route::post('search', ["as" => "search", "uses" => 'PropertyController@search']);
Route::get('page/{page}', ["as" => "page.show", "uses" => 'PageController@show']);
Route::get('blog', ["as" => "blog.index", "uses" => 'BlogController@index']);
Route::get('blog/{blog}', ["as" => "blog.show", "uses" => 'BlogController@show']);
Route::get('contact', ["as" => "home.contact", "uses" => 'HomeController@contact']);
Route::post('contact', ["as" => "home.contact", "uses" => 'HomeController@contactSend']);
Route::get('rss', ["as" => "home.rss", "uses" => "HomeController@rss"]);