Skip to content

Instantly share code, notes, and snippets.

@arungpisyadi
Last active December 13, 2016 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arungpisyadi/815d6dbdcd7ae4b887079974882be6d2 to your computer and use it in GitHub Desktop.
Save arungpisyadi/815d6dbdcd7ae4b887079974882be6d2 to your computer and use it in GitHub Desktop.
Cleaned backend code unused dealerListings
//$sql = "SELECT a.ID, a.post_date, a.post_title,a.post_content, a.post_name, b.meta_value,t.name as category_name , t.term_id,tax.taxonomy FROM wp_posts a inner JOIN wp_postmeta b inner JOIN wp_term_relationships rel ON rel.object_id = a.ID inner JOIN wp_term_taxonomy tax ON tax.term_taxonomy_id = rel.term_taxonomy_id inner JOIN wp_terms t ON t.term_id = tax.term_id WHERE a.post_status = 'publish' AND a.ID = b.post_id AND b.meta_key = '_thumbnail_id' AND tax.taxonomy = 'category' group by a.ID ORDER BY a.post_date DESC LIMIT 2;";
//#fiqi load ajax total listing()
function load_total_ajax($id){
if($id=='3d-estates'){
return $this->load_total_ajax_3d_estates($_REQUEST);
}else{
$data = DB::table('category_2')->where('id',$id)->first();
foreach ($_REQUEST['data'] as $key => $value) {
$_REQUEST[$key] = $value;
};
//get parent and child,
$childs = DB::table('category_2')->where('parent',$data->id)->get();
//array id parent
$cat_ids = array($data->id);
//array push the child *if has childs
foreach ($childs as $value) {
array_push($cat_ids,$value->id);
}
$search_arr = array();
$filters = array();
if(isset($_REQUEST['q']) && !empty($_REQUEST['q'])){
$search = $_REQUEST['q'];
$search = urldecode($search);
TNTSearch::selectIndex("luxify.index");
$index_list = TNTSearch::searchBoolean($search, 20000);
$search_query = $index_list['ids'];
}
if(isset($_REQUEST['filters']) && $_REQUEST['filters'] == 'on'){
$_filter = $_REQUEST;
if(!empty($_filter['location']) && $_filter['location'] != 'Location'){
$search_arr[] = ['countryId', $_filter['location']];
$filters['location'] = $_filter['location'];
}
if(isset($_filter['category']) && $_filter['category'] != 'Category'){
unset($cat_ids);
$cat_ids = array();
if(isset($_filter['sub_category']) && !empty($_filter['sub_category'])){
$sub_category = $_filter['sub_category'];
$childs = DB::table('category_2')->where('slug',$sub_category)->first();
$cat_ids = array($childs->id);
}else{
//get parent and child,
$data = DB::table('category_2')->where('slug',$_filter['category'])->first();
$childs = DB::table('category_2')->where('parent',$data->id)->get();
//array id parent
$cat_ids = array($data->id);
//array push the child *if has childs
foreach ($childs as $value) {
array_push($cat_ids,$value->id);
}
// var_dump($cat_ids); exit;
}
$filters['category'] = $_filter['category'];
}
if(isset($_REQUEST['use_price']) && $_REQUEST['use_price'] == 'on'){ // need to be put last to filter out the price range based on currency set.
$use_price = true;
$filters['use_price'] = 'on';
$price_lists = DB::table('listings')
->where('status', 'APPROVED')
->whereIn('new_category', $cat_ids)
->where($search_arr)
->join('countries', 'countries.id', '=', 'listings.countryId')
->select('listings.*', 'countries.name as country')
->get();
if($use_price && !empty($_REQUEST['range'])){
$price_range = explode(';', $_REQUEST['range']);
$filtered_listing = array();
foreach($price_lists as $key => $val){
$price_set = $val->price;
$currency = DB::table('currencies')->where('id', $val->currencyId)->first();
$set_curr = $currency->code;
$sess_curr = null !== session('currency') ? session('currency') : 'USD';
$session_currency = DB::table('currencies')->where('code', $sess_curr)->first();
if($set_curr != $sess_curr){
$price_sql = $price_set / $currency->rate;
$price = $price_sql * $session_currency->rate;
}else{
$price = $price_set;
}
if($price < $price_range[0] || $price > $price_range[1]){
// echo $key . ', ';
$filtered_listing[] = $val->id;
}
}
$filters['range'] = $_REQUEST['range'];
}
}else{
$use_price = false;
$filters['use_price'] = 'off';
}
}
// var_dump($cat_ids); exit;
if(isset($filtered_listing)){
// var_dump($filtered_listing); exit;
//#fiqi update 20160917
if(isset($search_query)){
$listings = DB::table('listings')
->where('status', 'APPROVED')
->whereIn('listings.new_category', $cat_ids)
->whereIn('listings.id',$search_query)
->whereNotIn('listings.id', $filtered_listing)
->select('listings.*')
->paginate(1);
}else{
$listings = DB::table('listings')
->where('status', 'APPROVED')
->whereIn('listings.new_category', $cat_ids)
->whereNotIn('listings.id', $filtered_listing)
->select('listings.*')
->paginate(1);
}
}else{
if(isset($search_query)){
$listings = DB::table('listings')
->where('status', 'APPROVED')
->whereIn('new_category', $cat_ids)
->whereIn('listings.id',$search_query)
->select('listings.*')
->paginate(1);
}else{
$listings = DB::table('listings')
->where('status', 'APPROVED')
->whereIn('new_category', $cat_ids)
->select('listings.*')
->paginate(1);
}
//#endfiqi update 20160917
}
return $listings->total();
}
}
function load_total_ajax_3d_estates($req){
foreach ($req['data'] as $key => $value) {
$_REQUEST[$key] = $value;
};
$filters = array();
$search_arr = array();
$filtered_listing = array();
if(isset($_REQUEST['q']) && !empty($_REQUEST['q'])){
$search = $_REQUEST['q'];
$search = urldecode($search);
TNTSearch::selectIndex("luxify.index");
$index_list = TNTSearch::searchBoolean($search, 20000);
$search_query = $index_list['ids'];
}
if(isset($_REQUEST['filters']) && $_REQUEST['filters'] == 'on'){
$_filter = $_REQUEST;
if(!empty($_filter['location']) && $_filter['location'] != 'Location'){
$search_arr[] = ['countryId', $_filter['location']];
$filters['location'] = $_filter['location'];
$ajax_filter['location'] = $_filter['location'];
}
if(!empty($_filter['sort-radio'])){
switch($_filter['sort-radio']){
case 'latest':
$orderby = 'created_at';
$order = 'desc';
break;
case 'priceUp':
$orderby = 'price';
$order = 'desc';
break;
case 'priceDown':
$orderby = 'price';
$order = 'asc';
break;
}
$filters['sort'] = $_filter['sort-radio'];
}
if(isset($_REQUEST['use_price']) && $_REQUEST['use_price'] == 'on'){ // need to be put last to filter out the price range based on currency set.
$ajax_filter['use_price'] = $_REQUEST['use_price'];
$use_price = true;
$filters['use_price'] = 'on';
$price_lists = DB::table('listings')
->where('status', 'APPROVED')
->where($search_arr)
->join('countries', 'countries.id', '=', 'listings.countryId')
->select('listings.*', 'countries.name as country')
->get();
if($use_price && !empty($_REQUEST['range'])){
$ajax_filter['range'] = $_REQUEST['range'];
$price_range = explode(';', $_REQUEST['range']);
foreach($price_lists as $key => $val){
$price_set = $val->price;
$currency = DB::table('currencies')->where('id', $val->currencyId)->first();
$set_curr = $currency->code;
$sess_curr = null !== session('currency') ? session('currency') : 'USD';
$session_currency = DB::table('currencies')->where('code', $sess_curr)->first();
if($set_curr != $sess_curr){
$price_sql = $price_set / $currency->rate;
$price = $price_sql * $session_currency->rate;
}else{
$price = $price_set;
}
if($price < $price_range[0] || $price > $price_range[1]){
// echo $key . ', ';
$filtered_listing[] = $val->id;
}
}
$filters['range'] = $_REQUEST['range'];
}
}else{
$use_price = false;
$filters['use_price'] = 'off';
}
}
if(isset($filtered_listing) && !empty($filtered_listing)){
if(isset($search_query)){
$listings = DB::table('listings')
->whereNotNull('aerialLook3DUrl')
->where('status', 'APPROVED')
->whereIn('listings.id',$search_query)
->whereNotIn('listings.id', $filtered_listing)
->where($search_arr)
->select('listings.*')
->paginate(1);
}else{
$listings = DB::table('listings')
->whereNotNull('aerialLook3DUrl')
->where('status', 'APPROVED')
->whereNotIn('listings.id', $filtered_listing)
->where($search_arr)
->select('listings.*')
->paginate(1);
}
} else {
if(isset($search_query)){
$listings = DB::table('listings')
->whereNotNull('aerialLook3DUrl')
->where('status', 'APPROVED')
->whereIn('listings.id',$search_query)
->where($search_arr)
->select('listings.*')
->paginate(1);
}else{
$listings = DB::table('listings')
->whereNotNull('aerialLook3DUrl')
->where('status', 'APPROVED')
->where($search_arr)
->select('listings.*')
->paginate(1);
}
}
return $listings->total();
}
/*
foreach ($formgroups as $fg) {
if($fg->type=='textfield'){
echo '<div class="col-sm-4"><label for="'. $data->label .'" class="control-label">'. $data->label .'</label><input id="'. $data->label .'" name="optionfields['. $data->id .']" type="text" class="form-control"></div>';
}elseif($type=='number'){
echo '<div class="col-sm-4"><label for="'. $data->label .'" class="control-label">'. $data->label .'</label><input id="'. $data->label .'" name="optionfields['. $data->id .']" type="text" class="form-control"></div>';
}elseif($type=='year'){
echo '<div class="col-sm-4"><label for="'. $data->label .'" class="control-label">'. $data->label .'</label><textarea id="'. $data->label .'" name="optionfields['. $data->id .']" class="form-control"></textarea></div>';
}elseif($type=='yearpick'){
echo '<div class="col-sm-4"><label for="'. $data->label .'" class="control-label">'. $data->label .'</label><textarea id="'. $data->label .'" name="optionfields['. $data->id .']" class="form-control"></textarea></div>';
}elseif($type=='dropdown' || $type=='select'){
echo '<div class="col-sm-4"><label for="'. $data->label .'" class="control-label">'. $data->label .'</label><select name="optionfields['. $data->id .']" class="form-control">';
foreach ($drop as $option) {
echo "<option value='".$option->value."'>".$option->text."</option>";
}
echo '</select></div>';
}elseif($type=='radiobutton'){
echo '<div class="col-sm-4"><label for="'. $data->label .'" class="control-label">'. $data->label .'</label></br>';
foreach ($drop as $option) {
echo "<input name='optionfields[".$data->id."]' type='radio' value='".$option->value."'>".$option->text."</br>";
}
echo '</div>';
}elseif($type=='checkbox'){
echo '<div class="col-sm-4"><label for="'. $data->label .'" class="control-label">'. $data->label .'</label></br>';
foreach ($drop as $option) {
echo "<input name='optionfields[".$data->id."]' type='checkbox' value='".$option->value."'>".$option->text."</br>";
}
echo '</div>';
}
}
*/
public function dealerListing($id){
$childs = array(
'estates' => array(50,69,16,52,72),
'apartment' => array(126,51,49),
'house' => array(48),
'land' => array(53,54),
'others' => array(47,138,57,56,127,15),
'antique_jewelry' => array(149),
'jewelry' => array(10,110,109,108,39,107,38,37),
'watch' => array(36,106,105,89,34,33,31),
'cars' => array(2,11,20,19,60,55,18),
'classic' => array(66),
'motorbike' => array(17),
'accessories_men' => array(92.88),
'accessories_women' => array(124, 160, 150, 120,119,118,117,161,159,116),
'bags' => array(9,43,114,113,42,41,112,111,91,137),
'experiences' => array(3,162,169,165,99,97,167,164,166,98,95,96,163,94),
'collectibles' => array(1,46,68,67,168,136,64, 70, 61,131,130,90),
'furnitures' => array(146, 79, 144, 63, 133, 62, 71, 93),
'motor' => array(40,25,24,23,85,76),
'sail' => array(22,24),
'jet' => array(45),
'helicopter' => array(125, 13),
'art' => array(12,59,58,129,128),
'antiques' => array(139,74,140,81,147,80,73,145,143,142,148,78,77,75,141,),
'fine_wines' => array(35,26,30,28,87,29),
'spirits' => array(100,101,170,171,102,103,172,173,104),
'champagne' => array(27)
);
$search_arr = array();
$search_arr[] = ['userId', $id];
// $search_arr[] = ['status', 'APPROVED'];
$orderby = 'created_at';
$order = 'desc';
$filters = array();
if(isset($_REQUEST['filters']) && $_REQUEST['filters'] == 'on'){
$_filter = $_REQUEST;
// var_dump($_filter); exit;
if(!empty($_filter['location']) && $_filter['location'] != 'Location'){
$search_arr[] = ['countryId', $_filter['location']];
$filters['location'] = $_filter['location'];
}
if(isset($_REQUEST['use_price']) && $_REQUEST['use_price'] == 'on'){
$use_price = true;
$filters['use_price'] = 'off';
}else{
$use_price = false;
$filters['use_price'] = 'off';
}
if($use_price && !empty($_REQUEST['range'])){
$price_range = explode(';', $_REQUEST['range']);
$search_arr[] = ['price', '>=', $price_range[0]];
$search_arr[] = ['price', '<=', $price_range[1]];
$filters['range'] = $_REQUEST['range'];
}
// var_dump($price_range); exit;
if(isset($_filter['category']) && $_filter['category'] != 'Category'){
unset($cat_ids);
$cat_ids = array();
if(isset($_filter['sub_category']) && !empty($_filter['sub_category'])){
// var_dump($childs['classics']);
$sub_category = $_filter['sub_category'];
// var_dump($sub_category);
switch($sub_category){
case 'estates':
$cat_ids = array(50,69,16,52,72);
break;
case 'apartment':
$cat_ids = array(126,51,49);
break;
case 'house':
$cat_ids =array(48);
break;
case 'land':
$cat_ids = array(53,54);
break;
case 'others':
$cat_ids = array(47,138,57,56,127,15);
break;
case 'antique_jewelry':
$cat_ids = array(149);
break;
case 'jewelry':
$cat_ids = array(10,110,109,108,39,107,38,37);
break;
case 'watch':
$cat_ids = array(36,106,105,89,34,33,31);
break;
case 'cars':
$cat_ids = array(2,11,20,19,60,55,18);
break;
case 'classics':
$cat_ids = array(66);
break;
case 'motorbike':
$cat_ids = array(17);
break;
case 'accessories_men':
$cat_ids = array(92,88);
break;
case 'accessories_women':
$cat_ids = array(124, 160, 150, 120,119,118,117,161,159,116);
break;
case 'bags':
$cat_ids = array(9,43,114,113,42,41,112,111,91,137);
break;
case 'experiences':
$cat_ids = array(3,162,169,165,99,97,167,164,166,98,95,96,163,94);
break;
case 'collectibles':
$cat_ids = array(1,46,68,67,168,136,64, 70, 61,131,130,90);
break;
case 'furnitures':
$cat_ids = array(146, 79, 144, 63, 133, 62, 71, 93);
break;
case 'motor':
$cat_ids = array(40,25,24,23,85,76);
break;
case 'sail':
$cat_ids = array(22,24);
break;
case 'jet':
$cat_ids = array(45);
break;
case 'helicopter':
$cat_ids = array(125, 13);
break;
case 'art':
$cat_ids = array(12,59,58,129,128);
break;
case 'antiques':
$cat_ids = array(139,74,140,81,147,80,73,145,143,142,148,78,77,75,141,);
break;
case 'fine_wines':
$cat_ids = array(35,26,30,28,87,29);
break;
case 'spirits':
$cat_ids = array(100,101,170,171,102,103,172,173,104);
break;
case 'champagne':
$cat_ids = array(27);
break;
}
// var_dump($cat_ids); exit;
}else{
switch($_filter['category']){
case 'real-estates':
$cat_ids = array_merge($childs['estates'],$childs['apartment'],$childs['house'],$childs['land'],$childs['others']);
$banner = 'banner-estate.jpg';
break;
case 'jewellery-watches':
$cat_ids = array_merge($childs['antique_jewelry'],$childs['jewelry'],$childs['watch']);
$banner = 'watches_banner.jpg';
break;
case 'motors':
$cat_ids = array_merge($childs['cars'],$childs['classic'],$childs['motorbike']);
$banner = 'motors_banner.jpg';
break;
case 'handbags-accessories':
$cat_ids = array_merge($childs['accessories_men'],$childs['accessories_women'],$childs['bags']);
$banner = 'bags_banner_bk.jpg';
break;
case 'experiences':
$cat_ids = array_merge($childs['experiences']);
$banner = 'experience_banner.jpg';
break;
case 'collectibles-furnitures':
$cat_ids = array_merge($childs['collectibles'],$childs['furnitures']);
$banner = 'Collectibles_banner.jpg';
break;
case 'yachts':
$cat_ids = array_merge($childs['motor'],$childs['sail']);
$banner = 'banner-whyluxify.jpg';
break;
case 'aircrafts':
$cat_ids = array_merge($childs['jet'],$childs['helicopter']);
$banner = 'about-banner.jpg';
break;
case 'art-antiques':
$cat_ids = array_merge($childs['art'],$childs['antiques']);
$banner = 'arts_banner.jpg';
break;
case 'fine-wines-spirits':
$cat_ids = array_merge($childs['fine_wines'],$childs['spirits'],$childs['champagne']);
$banner = 'wine_banner.jpg';
break;
}
}
$filters['category'] = $_filter['category'];
}
if(!empty($_filter['sort-radio'])){
switch($_filter['sort-radio']){
case 'latest':
$orderby = 'created_at';
$order = 'desc';
break;
case 'priceUp':
$orderby = 'price';
$order = 'desc';
break;
case 'priceDown':
$orderby = 'price';
$order = 'asc';
break;
}
$filters['sort'] = $_filter['sort-radio'];
}
}
if(isset($cat_ids)){
$listings = DB::table('listings')
->where($search_arr)
->whereIn($cat_ids)
->orderBy($orderby, $order)
->paginate(51);
}else{
$listings = DB::table('listings')
->where($search_arr)
->orderBy($orderby, $order)
->paginate(51);
}
$locs = '';
$cats = '';
if(is_array($listings) && !empty($listings)){
foreach($listings as $list){
$loc_arr[] = $list->countryId;
$cat_arr[] = $list->new_category;
$cond_arr[] = $list->condition;
}
$locs = $this->get_column('countries', $loc_arr);
$locs = array_values(array_sort($locs, function ($value) {
return $value['name'];
}));
$cats = $this->get_column('categories', $cat_arr);
$cats = array_values(array_sort($cats, function ($value) {
return $value['title'];
}));
}
// 2016-11-04 Martins Rewrite Handle Empty query
$ref = $_SERVER['REQUEST_URI'];
$reqURL = parse_url($ref);
parse_str((isset($reqURL['query'])?$reqURL['query']:''), $params);
$requestPage = isset($params['page'])? intval($params['page']):null;
$params = collect($params)
->except(['page', '_pjax', 'user_id'])
->filter(function($value, $key) {
return !empty($value);
})
->toArray();
if ($requestPage && $requestPage > $listings->lastPage()) {
return redirect($reqURL['path'] . '?page='.$listings->lastPage() . (count($params)>0 ? ('&'. http_build_query($params)) : ''));
}
$ref = $reqURL['path'] . (count($params)>0 ? ('?'. http_build_query($params)) : '');
$listings->setPath($ref);
return view('dealer-listings', ['listings' => $listings, 'filters' => $filters]);
}
public function searchAjaxJson() {
$returnArr = array();
if(isset($_POST['action']) && isset($_POST['search'])){
$action = $_POST['action'];
if($action == 'search'){
searchResultDataBase();
if($listings && !empty($listings)){
ob_start();
$return = '<div class="col-sm-7">';
$return .= '<div class="row-header"><a href="/search?_token='.$_POST['_token'].'&action='.$_POST['action'].'&refine_text='. $search .'" class="pull-right" title="View More">More</a><div class="category-label"><span>Showing '.$listings->count().' of '.$listings->total().' result(s)</span></div></div>';
$return .= '<ul class="results-found">';
foreach($listings as $list){
$cats[] = $list->new_category;
//outputting left rows
$return .= '<li>';
$return .= '<a href="/listing/'. $list->slug.'" title="'. $list->title .'">';
$item_img = !empty($list->mainImageUrl) ? $list->mainImageUrl : 'default-logo.png';
$return .= '<img class="result-img" src="/img/ring.gif" data-src="https://images.luxify.com/55/https%3A%2F%2Fluxify.s3-accelerate.amazonaws.com/images/'. $item_img .'" width="35" height="35" alt="Image">';
$return .= '<div class="result-title">'.$list->title.'</div>';
//fixes for currency
$sess_currency = null !== session('currency') ? session('currency') : 'USD';
$price_format = func::formatPrice($list->currencyId, $sess_currency, $list->price);
$return .= '<div class="price" style="margin-left: 15px;">'. $price_format .'</div>';
$return .= '</a>';
$return .= '</li>';
}
$return .= '</ul>';
$return .= '</div>';
$dealers = array_unique($dealers);
$dealers = array_filter($dealers);
$return .= '<div class="col-sm-5 hidden-xs">';
$return .= '<div class="row-header"> <a style="display: none;" href="javascript:void(0);" class="pull-right" title="View More">More</a><div class="category-label"><span>Recomended Sellers</span></div></div>';
$return .= '<ul class="results-found recommended">';
foreach($dealers as $d){
$dealer = DB::table('users')
->where('id', $d)
->first();
// dd($dealer);
$return .= '<li>';
// Arung - Fix #6 - Search Algorithm Accuracy
if(isset($dealer->companyName) && $dealer->companyName != ''){
$companyName = json_decode($dealer->companyName);
if($companyName != NULL){
$coName = $companyName[0] . ' ' . $companyName[1];
}else{
$coName = !empty($dealer->companyName)? $dealer->companyName : $dealer->firstName . ' ' . $dealer->lastName;
}
}else{
$coName = '';
}
if((isset($dealer->firstName) && $dealer->firstName != '') || (isset($dealer->lastName) && $dealer->lastName != '')){
$slug_alt = strtolower($dealer->firstName).'-'.strtolower($dealer->lastName);
}elseif($coName != NULL){
$slug_alt = strtolower($coName);
}else{
$slug_alt = '';
}
$slug = isset($dealer->slug) && $dealer->slug != '' ? $dealer->slug : $slug_alt;
if(isset($dealer->id)){
$return .= '<a href="/dealer/'.$dealer->id.'/'.$slug.'" title="'.$coName.'">';
}else{
$return .= '<a href="javascript:;" title="'.$coName.'">';
}
$dealer_img = !empty($dealer->companyLogoUrl) ? $dealer->companyLogoUrl : 'default-logo.png';
$return .= '<img src="https://images.luxify.com/150/https%3A%2F%2Fluxify.s3-accelerate.amazonaws.com/images/'. $dealer_img .'" width="35" height="35" alt="Image">';
$return .= '<span style="display: block; margin-top: 10px;">'. $coName . '</span>';
// end Arung - Fix #6 - Search Algorithm Accuracy
$return .= '</a>';
$return .= '</li>';
}
$return .= '</ul>';
$return .= '</div>';
// $return .= '<script>$("img.result-img").unveil(); $(window).trigger("unveil")</script>';
ob_end_flush();
$return = rtrim($return, $search);
// echo $return;
// echo rtrim($return, $search);
echo $return;
}else{
echo '<p>No matching result.</p>';
}
}
}
}
public function products_old($id) {
$dealer = DB::table('users')
->where('slug', $id)
->leftJoin('countries', 'countries.id', '=', 'users.countryId')
->select('users.*', 'countries.name as country')
->first();
$listings = DB::table('listings')
->where('userId', $dealer->id)
->where('status', 'APPROVED')
->join('countries', 'countries.id', '=', 'listings.countryId')
->select('listings.*', 'countries.name as country')
->orderBy('created_at', 'desc')
->paginate(30);
//add meta
$meta = new Meta;
$meta->title = trim(Meta::get_data_user($dealer->id,'title'));
if(!empty($meta->title) && ($meta->title !=null)){
$meta->title = substr(Meta::get_data_user($dealer->id,'title'),0,60);
}else{
if(!empty($dealer->companyName) && ($dealer->companyName)!= null){
$company = json_decode($dealer->companyName);
if(is_array($company)){
$meta->title = substr($company[0].' '.$company[1],0,60);
}else{
$meta->title = substr(ucfirst($dealer->firstName) . ' ' . ucfirst($dealer->lastName),0,60);
}
}else{
$meta->title = substr(ucfirst($dealer->firstName) . ' ' . ucfirst($dealer->lastName),0,60);
}
}
$meta->alt_text = Meta::get_data_user($dealer->id,'alt_text');
$meta->description = !empty(Meta::get_data_listing($dealer->id,'companySummary')) ? Meta::get_data_listing($dealer->id,'companySummary') : str_limit(trim(preg_replace('/\s\s+/', ' ', $dealer->companySummary, 160)));
$meta->author = trim(Meta::get_data_user($dealer->id,'author'));
if(!empty($meta->author) && ($meta->author !=null)){
$meta->author = Meta::get_data_user($dealer->id,'author');
}else{
if(!empty($dealer->companyName) && ($dealer->companyName)!= null){
$company = json_decode($dealer->companyName);
if(is_array($company)){
$meta->author = $company[0];
}else{
$meta->author = ucfirst($dealer->firstName) . ' ' . ucfirst($dealer->lastName);
}
}else{
$meta->author = ucfirst($dealer->firstName) . ' ' . ucfirst($dealer->lastName);
}
}
$meta->keyword = Meta::get_data_user($dealer->id,'keyword');
$banner = !empty($dealer->coverImageUrl) ? $dealer->coverImageUrl : 'about-banner.jpg';
$opengraphs = [
'site_name' => strip_tags($meta->title),
'title' => strip_tags($meta->title),
'description' => strip_tags(func::trimDownText($meta->description, 160)),
'image' => urldecode(func::img_url($banner, '', 320)),
'updated_at' => strtotime($dealer->updated_at)
];
return view('listings', ['listings' => $listings,'meta' => $meta,'opengraphs' =>$opengraphs, 'dealer' => $dealer]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment