/** * Run the database seeds. * * @return void */ public function run() { $names = ['Chưa xác định', '<= 30 m2', '30 - 50 m2', '50 - 80 m2', '80 - 100 m2', '100 - 150 m2', '150 - 200 m2', '200 - 250 m2', '250 - 300 m2', '300 - 500 m2', '>= 500 m2']; $from = [0, 0, 30, 50, 80, 100, 150, 200, 250, 300, 500]; $to = [0, 29, 50, 80, 100, 150, 200, 250, 300, 500, 1000]; foreach ($names as $key => $value) { $project_type = Area_range::create(['key' => Common::createKeyURL($value), 'name' => $value, 'from' => $from[$key], 'to' => $to[$key], 'priority' => $key, 'active' => 1, 'created_by' => 'vankhoeseed', 'updated_by' => 'vankhoeseed']); } }
/** * List Area_range ajax. */ public function getAreaRange(Request $request) { $object = Area_range::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get(); return $object->toArray(); }
public function product_detail($product_id, $product_key) { $product = Product::findOrFail($product_id); if ($product != null) { $price_ranges = Price_range::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get(); $area_ranges = Area_range::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get(); $incense_types = Incense_type::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get(); // metadata $site_title = $product->title . ' - ' . Config::findByKey('site_title')->first()->value; SEOMeta::setTitle($site_title); SEOMeta::setDescription($product->meta_description); SEOMeta::addKeyword([$product->meta_keywords]); SEOMeta::addMeta('product:published_time', $product->created_at->toW3CString(), 'property'); if (isset($product->product_type->name)) { SEOMeta::addMeta('product:section', $product->product_type->name, 'property'); } OpenGraph::setTitle($site_title); OpenGraph::setDescription($product->meta_description); OpenGraph::setUrl($product->getLink()); OpenGraph::addProperty('type', 'product'); OpenGraph::addProperty('locale', app()->getLocale()); OpenGraph::addProperty('locale:alternate', ['vi-vn', 'en-us']); OpenGraph::addImage($product->getThumnail()); OpenGraph::addImage($product->attachments->lists('path')); OpenGraph::addImage(['url' => Image::url($product->getThumnail(), 300, 300, array('crop')), 'size' => 300]); // end metadata $attachments = $product->attachments()->take(5)->get(); $wards = $product->district->wards; $heading = $product->product_type->name . ' ' . (isset($product->ward_id) && $product->ward_id > 0 ? $product->ward->name : $product->district->name); // $link =''; if (isset($product->ward_id) && $product->ward_id > 0) { $link = route('product_type_province_district_ward', ['product_type_key' => $product->product_type->key, 'province_key' => $product->province->key, 'district_key' => $product->district->key, 'ward_key' => $product->ward->key]); $relate_products = $product->ward->products()->where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->take(5)->get(); if (count($relate_products) == 0) { $relate_products = $product->district->products()->where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->take(5)->get(); } } else { $link = route('product_type_province_district', ['product_type_key' => $product->product_type->key, 'province_key' => $product->province->key, 'district_key' => $product->district->key]); $relate_products = $product->district->products()->where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->take(5)->get(); } $breadcrumb = '<ul class="breadcrumb pull-left padl0"> <li class="active"><a href="' . route('homepage') . '">Trang chủ</a></li> <li class="active"><a href="' . route('products') . '">Căn hộ</a></li> <li class="active"><a href="' . route('product_type', ['product_type_key' => $product->product_type->key]) . '">' . $product->product_type->name . '</a></li> <li class="active"><a href="' . route('product_type_province', ['product_type_key' => $product->product_type->key, 'province_key' => $product->province->key]) . '">' . $product->province->name . '</a></li> <li class="active"><a href="' . route('product_type_province_district', ['product_type_key' => $product->product_type->key, 'province_key' => $product->province->key, 'district_key' => $product->district->key]) . '">' . $product->district->name . '</a></li> ' . (isset($product->ward_id) && $product->ward_id > 0 ? '<li class=""><a href="' . $link . '">' . $product->ward->name . '</a></li> ' : '') . ' </ul>'; return view('frontend.sites1.product_detail', ['product' => $product, 'attachments' => $attachments, 'product_type' => $product->product_type, 'wards' => $wards, 'price_ranges' => $price_ranges, 'area_ranges' => $area_ranges, 'incense_types' => $incense_types, 'relate_products' => $relate_products, 'search_type' => 'product_detail', 'link' => $link, 'breadcrumb' => $breadcrumb, 'heading' => $heading]); } else { return view('frontend.sites1.product_detail'); } }