So, I have a problem with displaying for a few posts.After a post was deactivated, on main isn't showing anymore, but the space is still here, even if I have an #if condition.By default, on my page I have 7 posts on every page, but here is remaining only the posts which is activated ( table event, column activate)
Here is the code from main
<div class="clearfix margin-bottom-20"><hr></div>
<!-- News v3 -->
#foreach($events as $event)
#if($event->active != 1)
<div class="row margin-bottom-20">
<div class="col-sm-5 sm-margin-bottom-20">
<div class="easy-block-v1">
<a href="{{ url('topic') }}/{{ $event->category->category_url }}">
<div class="easy-block-v1-badge rgba-{{ $event->category->color }} noticeboard-topic-category">
<i class="icon-hotel-restaurant-183 u-line-icon-pro fa-"></i> / {{ $event->category->category }}
</div>
</a>
<?php
$video_content = preg_replace("/<img[^>]+\>/i", "", $event->information);
preg_match('/src="([^"]+)"/', $video_content, $video);
?>
<?php
$match = '';
$str = $event->information;
$start = "<iframe src='";
$end = "' width='100%' height='281'></iframe>";
$pattern = sprintf(
'/%s(.+?)%s/ims',
preg_quote($start, '/'), preg_quote($end, '/')
);
if (preg_match($pattern, $str, $matches)) {
list(, $match) = $matches;
}
?>
#if(isset($match) && $match != '')
<iframe src="{{ $match }}" width='100%' height='250'></iframe>
#elseif(isset($video[1]))
<iframe src="{{ $video[1] }}" width='100%' height='250'></iframe>
#else
<?php preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i', $event->information, $image); ?>
#if(isset($image['src']))
<!-- <img class="img-responsive" src="{{ $image['src'] }}" alt=""> -->
<?php $img = str_replace('&', '&', $image['src']); ?>
<img class="img-responsive" src="{{ url('ass/336/212?'.$img) }}" alt="">
#else
<?php $img = "thumbnail/".$event->user->profile_picture; ?>
#if(#getimagesize($img))
<img src="{{ url('ass/336/212?'.$img) }}" alt='' />
#else
<?php $img = "assets/img/main/img12.jpg"; ?>
<img class="img-responsive" src="{{ url('ass/336/212?'.$img) }}" alt="">
#endif
#endif
#endif
</div>
</div>
<div class="col-sm-7 news-v3">
<div class="news-v3-in-sm no-padding">
<h2>{{ $event->subject }}</h2>
<ul class="list-inline" style="right: 10px;position: relative">
<li style="font-style: normal !important">
<li style="font-style: normal !important">
#if($event->user->role[0]->pivot->role_id == 1)
<i style="margin-right: 2px;margin-left: 3px;font-size: 11px" class="icon-user"></i>
#else
<i style="margin-right: 2px;margin-left: 3px;font-size: 11px" class="icon-hotel-restaurant-172 u-line-icon-pro fa- fa-lg"></i>
#endif
<a style="margin-left: 2px" href="{{ url('') }}/{{ $event->user->username }}">{{ $event->user->username }}</a></li>
<li style="font-style: normal !important"><i style="margin-right: 3px" class="icon-hotel-restaurant-183 u-line-icon-pro fa-"></i> <a href="{{ url('view-all-event') }}">Event</li>
<li style="font-style: normal !important"><i style="margin-right: 3px" class="icon-notebook fa-"></i> {{ $event->category->category }}</li>
</ul>
<?php
$information = preg_replace("/<img[^>]+\>/i", "", $event->information);
$Output = preg_replace('/<iframe.*?\/iframe>/i','', $information);
?>
<p>{{ str_limit(trim(strip_tags(preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $Output))), 200) }}</p>
<ul class="social-icons social-icons-color social-cu-icons" style="display:none;">
<div class="social-cu">
<li class="facebook_share share_link" link="{{ url('view-event') }}/{{ $event->id }}_{{ Slugify::slugify($event->subject) }}" name="{{ $event->subject }}" description="{{ $event->subject }}">
</li>
<li class="google_share share_link" link="{{ url('view-event') }}/{{ $event->id }}_{{ Slugify::slugify($event->subject) }}" name="{{ $event->subject }}" description="{{ $event->subject }}">
</li>
<li class="twitter_share share_link" link="{{ url('view-event') }}/{{ $event->id }}_{{ Slugify::slugify($event->subject) }}" name="{{ $event->subject }}" description="{{ $event->subject }}">
</li>
<li class="whatapp_share share_link" link="{{ url('view-event') }}/{{ $event->id }}_{{ Slugify::slugify($event->subject) }}" name="{{ $event->subject }}" description="{{ $event->subject }}">
<a href="whatsapp://send?text={{ url('view-event') }}/{{ $event->id }}_{{ Slugify::slugify($event->subject) }}">
<img class="img-responsive social_whatsapp" src="{{ asset('/assets/img/icons/social/Whatsapp.png') }}" alt="">
</a>
</li>
</div>
</ul>
<ul class="post-shares post-shares-lg">
<li ><i class="rounded-x fa fa-comments-o "><span>{!! $event->event_comment_count !!}</span></i></li>
<li><i class="rounded-x icon-magnifier-add" ><span>{!! $event->views !!}</span></i></li>
<li class="changeview" value="{{ $event->id }}" id="changeview"><i class="rounded-x icon-like "><span class="like_{{ $event->id }}">{!! $event->event_like_count !!}</span></i></li>
<li class="share-link"><i class="rounded-x icon-share"></i></li>
</ul>
<br>
Read more...
</div>
</div>
</div><!--/end row-->
<!-- End News v3 -->
<div class="clearfix margin-bottom-20"><hr></div>
#endif
#endforeach
My controller
public function viewAllEvent($category_id = null,$event_type_id = null,$country_id = null,$starting_date = null,$username = null,$search = null,$page = null)
{
// $eventrecommended = Event::with('user','category','country','event_type','event_like')->withCount('event_like','event_comment')->whereHas('user.contact', function ($query) use ($id) {
// $query->where('contacts.user_id', '=', $id);
// })->orWhere('events.public', '=', 1)->orWhere('events.user_id', '=', $id);
// if($page == ""){
// return redirect('view-all-event/1');
// }
$data = $this->data;
$data['title'] = "View All Event";
$data['breadcrumbs'] = "Events";
$page = Input::get('page');
$perPage = 7;
$offset = ($page * $perPage) - $perPage;
$data['evnetTypeList'] = \App\EventType::all();
$data['countryList'] = [''=>'Country'] + \App\Country::lists('country','code')->toArray();
$data['category'] = Input::get('category');
$data['event_type'] = Input::get('event_type');
$data['country'] = Input::get('country');
$data['starting_date'] = Input::get('starting_date');
$username = Input::get('username');
$search = Input::get('search');
$data['login_user'] = $username;
$data['search'] = $search;
$categoryID = \App\Category::pluck('id');
$event = Event::with('user','category','country','event_type')->withCount('event_like','event_comment')->whereHas('user', function($query) {
$query->where('deleted_at', '=', null);
})->whereIn('category_id',$categoryID);
$eventrecommended = Event::with('user','category','country','event_type','event_like')->whereHas('user', function($query) {
$query->where('deleted_at', '=', null);
})->withCount('event_like','event_comment')->whereIn('category_id',$categoryID);
if ($user = Sentinel::check())
{
if(!$user->inRole('admins'))
{
$id = $user->id;
$event = $event->Where(function($query1) use($id){
$query1->where('public','=', 1)->orWhereHas('user.contact', function ($query) use ($id) {
$query->where('user_id', '=', $id);
})->orWhere('user_id','=',$id);
});
$eventrecommended = $eventrecommended->Where(function($query1) use($id){
$query1->where('public','=', 1)->orWhereHas('user.contact', function ($query) use ($id) {
$query->where('user_id', '=', $id);
})->orWhere('user_id','=',$id);
});
}
}
else{
$event = $event->where('public','=', 1);
$eventrecommended = $eventrecommended->where('public','=', 1);
}
return view('event.view_all_event',$data);
}
And in the second photo is my noticeboard, which I have same problem...
Add to your $event in your controller
where('active', 0)
and delete the if statment in your view
#if($event->active != 1)
#endif
Related
when I click on a profile in the foreach loop, the "active" property of all "active" classes is deleted, not just the profile I clicked. How can I fix it so that only what I click is deleted? I do not want all "active" classes to be deleted, but only the active class property you clicked.
#foreach($other_user['details'] as $user)
#php
$user_id = Auth::user()->id;
$withid= $user->id;
$getunreadcount = \Models\Members::getlastconverunread($user_id,$withid);
#endphp
<a href="javascript:void(0);" data-conversation="{{$user->lastConver != null ? 'true' :'false'}}" data-id="{{ $user->username }}" #if($getunreadcount > 0) class="list-group-item list-group-item-action border-0 active userlink {{$user->lastConver != null ? ' ' :'hidden'}}" #else class="list-group-item list-group-item-action border-0 userlink {{$user->lastConver != null ? ' ' :'hidden'}}" #endif >
<div class="d-flex align-items-start">
#if($user->user_photo!='')
<img src="{{ url('/') }}/public/storage/users/{{ $user->user_photo }}" class="rounded-circle mr-1" alt="{{ $user->username }}" width="40" height="40">
#else
<img class="rounded-circle mr-1" width="40" height="40" src="{{ url('/') }}/public/img/no-user.png" alt="{{ $user->username }}" />
#endif
<div class="flex-grow-1 ml-3">
<span class="userName">
{{ $user->username }}
</span>
#if($getunreadcount > 0)
<div class="small unread"><span class="badge badge-warning">{{$getunreadcount}} Yeni Mesaj</span></div>
#endif
</div>
</div>
</a>
#endforeach
JQUERY:
$('.userlink').click(function(e) {
e.preventDefault();
var id = $(this).data("id");
var token = $("meta[name='csrf-token']").attr("content");
$('.userlink').removeClass('active');
var $this = $(this);
if (!$this.hasClass('active')) {
$this.removeClass('active');
}
});
I will be glad if you help me thank you.
$('.userlink').click(function(e) {
e.preventDefault();
...
// Like this:
$(this).removeClass('active');
});
I want to add my slider to my home page and when i add using #inclued method and it returns error undefended variable in slider page but it works well in slider page however i added it to home page error occurs. how do i correct this.
error msg-
Undefined variable $data (View: \resources\views\frontendslider.blade.php)
In the: \resources\views/frontendslider.blade.php file at line: 29
codes....
homepage
* LaraClassifier - Classified Ads Web Application
* Copyright (c) BeDigit. All Rights Reserved
*
* Website: https://laraclassifier.com
*
* LICENSE
* -------
* This software is furnished under a license and may be used and copied
* only in accordance with the terms of such license and with the inclusion
* of the above copyright notice. If you Purchased from CodeCanyon,
* Please read the full License from here - http://codecanyon.net/licenses/standard
--}}
#extends('layouts.master')
#section('search')
#parent
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.form', 'search.inc.form'])
#endsection
#section('content')
<div class="main-container">
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.breadcrumbs', 'search.inc.breadcrumbs'])
#if (config('settings.list.show_cats_in_top'))
#if (isset($cats) && $cats->count() > 0)
<div class="container mb-2 hide-xs">
<div class="row p-0 m-0">
<div class="col-12 p-0 m-0 border border-bottom-0 bg-light"></div>
</div>
</div>
#endif
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.categories', 'search.inc.categories'])
#endif
<?php if (isset($topAdvertising) && !empty($topAdvertising)): ?>
#includeFirst([config('larapen.core.customizedViewPath') . 'layouts.inc.advertising.top', 'layouts.inc.advertising.top'], ['paddingTopExists' => true])
<?php
$paddingTopExists = false;
else:
if (isset($paddingTopExists) && $paddingTopExists) {
$paddingTopExists = false;
}
endif;
?>
<div class="container">
<div class="row">
{{-- Sidebar --}}
#if (config('settings.list.left_sidebar'))
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.sidebar', 'search.inc.sidebar'])
<?php $contentColSm = 'col-md-9'; ?>
#else
<?php $contentColSm = 'col-md-12'; ?>
#endif
{{-- Content --}}
<div class="{{ $contentColSm }} page-content col-thin-left mb-4">
<div class="category-list {{ config('settings.list.display_mode', 'make-grid') }}{{ ($contentColSm == 'col-md-12') ? ' noSideBar' : '' }}">
<div class="tab-box">
{{-- Nav tabs --}}
<ul id="postType" class="nav nav-tabs add-tabs tablist" role="tablist">
<?php
$aClass = '';
$spanClass = 'alert-danger';
if (config('settings.single.show_listing_types')) {
if (!request()->filled('type') || request()->get('type') == '') {
$aClass = ' active';
$spanClass = 'bg-danger';
}
} else {
$aClass = ' active';
$spanClass = 'bg-danger';
}
?>
<li class="nav-item">
<a href="{!! qsUrl(request()->url(), request()->except(['page', 'type']), null, false) !!}" class="nav-link{{ $aClass }}">
{{ t('All Listings') }} <span class="badge badge-pill {!! $spanClass !!}">{{ $count->get('all') }}</span>
</a>
</li>
#if (config('settings.single.show_listing_types'))
#if (isset($postTypes) && $postTypes->count() > 0)
#foreach ($postTypes as $postType)
<?php
$postTypeUrl = qsUrl(
request()->url(),
array_merge(request()->except(['page']), ['type' => $postType->id]),
null,
false
);
$postTypeCount = ($count->has($postType->id)) ? $count->get($postType->id) : 0;
?>
#if (request()->filled('type') && request()->get('type') == $postType->id)
<li class="nav-item">
<a href="{!! $postTypeUrl !!}" class="nav-link active">
{{ $postType->name }}
<span class="badge badge-pill bg-danger">
{{ $postTypeCount }}
</span>
</a>
</li>
#else
<li class="nav-item">
<a href="{!! $postTypeUrl !!}" class="nav-link">
{{ $postType->name }}
<span class="badge badge-pill alert-danger">
{{ $postTypeCount }}
</span>
</a>
</li>
#endif
#endforeach
#endif
#endif
</ul>
<div class="tab-filter pb-2">
{{-- OrderBy Desktop --}}
<select id="orderBy" title="sort by" class="niceselecter select-sort-by small" data-style="btn-select" data-width="auto">
#if (isset($orderByArray) && !empty($orderByArray))
#foreach($orderByArray as $option)
#if ($option['condition'])
<option{{ $option['isSelected'] ? ' selected="selected"' : '' }} value="{!! $option['url'] !!}">
{{ $option['label'] }}
</option>
#endif
#endforeach
#endif
</select>
</div>
</div>
<div class="listing-filter">
<div class="float-start col-md-9 col-sm-8 col-12">
<h1 class="h6 pb-0 breadcrumb-list">
{!! (isset($htmlTitle)) ? $htmlTitle : '' !!}
</h1>
<div style="clear:both;"></div>
</div>
{{-- Display Modes --}}
#if (isset($posts) && $posts->count() > 0)
<?php $currDisplay = config('settings.list.display_mode'); ?>
<div class="float-end col-md-3 col-sm-4 col-12 text-end listing-view-action">
#if (isset($displayModesArray) && !empty($displayModesArray))
#foreach($displayModesArray as $displayMode => $value)
<span class="grid-view{{ ($currDisplay == $displayMode) ? ' active' : '' }}">
#if ($currDisplay == $displayMode)
<i class="fas fa-th-large"></i>
#else
<a href="{!! $value['url'] !!}">
<i class="{{ $value['icon'] }}"></i>
</a>
#endif
</span>
#endforeach
#endif
</div>
#endif
<div style="clear:both"></div>
</div>
{{-- Mobile Filter Bar --}}
<div class="mobile-filter-bar col-xl-12">
<ul class="list-unstyled list-inline no-margin no-padding">
#if (config('settings.list.left_sidebar'))
<li class="filter-toggle">
<a class=""><i class="fas fa-bars"></i> {{ t('Filters') }}</a>
</li>
#endif
<li>
{{-- OrderBy Mobile --}}
<div class="dropdown">
<a class="dropdown-toggle" data-bs-toggle="dropdown">{{ t('Sort by') }}</a>
<ul class="dropdown-menu">
#if (isset($orderByArray) && !empty($orderByArray))
#foreach($orderByArray as $option)
#if ($option['condition'])
<li>{{ $option['label'] }}</li>
#endif
#endforeach
#endif
</ul>
</div>
</li>
</ul>
</div>
<div class="menu-overly-mask"></div>
{{-- Mobile Filter bar End--}}
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="contentAll" role="tabpanel" aria-labelledby="tabAll">
<div id="postsList" class="category-list-wrapper posts-wrapper row no-margin">
<div class="slider">
#include('frontendslider')
</div>
#if (config('settings.list.display_mode') == 'make-list')
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.posts.template.list', 'search.inc.posts.template.list'])
#elseif (config('settings.list.display_mode') == 'make-compact')
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.posts.template.compact', 'search.inc.posts.template.compact'])
#else
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.posts.template.grid', 'search.inc.posts.template.grid'])
#endif
</div>
</div>
</div>
<div class="tab-box save-search-bar text-center">
#if (request()->filled('q') && request()->get('q') != '' && $count->get('all') > 0)
<a id="saveSearch"
data-name="{!! qsUrl(request()->url(), request()->except(['_token', 'location']), null, false) !!}"
data-count="{{ $count->get('all') }}"
>
<i class="far fa-bell"></i> {{ t('Save Search') }}
</a>
#else
#endif
</div>
</div>
#if ($posts->hasPages())
<nav class="mt-3 mb-0 pagination-sm" aria-label="">
{!! $posts->appends(request()->query())->links() !!}
</nav>
#endif
</div>
</div>
</div>
{{-- Advertising --}}
#includeFirst([config('larapen.core.customizedViewPath') . 'layouts.inc.advertising.bottom', 'layouts.inc.advertising.bottom'])
{{-- Promo Listing Button --}}
<div class="container mb-3">
<div class="card border-light text-dark bg-light mb-3">
<div class="card-body text-center">
<h2>{{ t('do_you_have_anything') }}</h2>
<h5>{{ t('sell_products_and_services_online_for_free') }}</h5>
#if (!auth()->check() && config('settings.single.guests_can_post_listings') != '1')
{{ t('start_now') }}
#else
{{ t('start_now') }}
#endif
</div>
</div>
</div>
{{-- Category Description --}}
#if (isset($cat, $cat->description) && !empty($cat->description))
#if (!(bool)$cat->hide_description)
<div class="container mb-3">
<div class="card border-light text-dark bg-light mb-3">
<div class="card-body">
{!! $cat->description !!}
</div>
</div>
</div>
#endif
#endif
{{-- Show Posts Tags --}}
#if (config('settings.list.show_listings_tags'))
#if (isset($tags) && !empty($tags))
<div class="container">
<div class="card mb-3">
<div class="card-body">
<h2 class="card-title"><i class="fas fa-tags"></i> {{ t('Tags') }}:</h2>
#foreach($tags as $iTag)
<span class="d-inline-block border border-inverse bg-light rounded-1 py-1 px-2 my-1 me-1">
<a href="{{ \App\Helpers\UrlGen::tag($iTag) }}">
{{ $iTag }}
</a>
</span>
#endforeach
</div>
</div>
</div>
#endif
#endif
</div>
#endsection
#section('modal_location')
#includeFirst([config('larapen.core.customizedViewPath') . 'layouts.inc.modal.location', 'layouts.inc.modal.location'])
#endsection
#section('after_scripts')
<script>
$(document).ready(function () {
$('#postType a').click(function (e) {
e.preventDefault();
var goToUrl = $(this).attr('href');
redirect(goToUrl);
});
$('#orderBy').change(function () {
var goToUrl = $(this).val();
redirect(goToUrl);
});
});
</script>
#endsection
controller
public function frontendslider(Request $request){
$data=slider::all();
return view('frontendslider',compact('data'));
}
public function frontendslider2(Request $request){
$data=slider::all();
return view('return',compact('data'));
}
web.php
Route::get('frontendslider',[App\Http\Controllers\Admin\SliderController::class,'frontendslider']);
Route::get('return',[App\Http\Controllers\Admin\SliderController::class,'frontendslider2']);
Anyone face like this kind of issue specelly working with lara classifers use this before your importing page or page that content update..
#php
$data=DB::table('slider')->get();
#endphp
PLS note input your data to $data and table name!!!!
I have three tables
categories
galleries
category_gallery
I want to create like this site . http://onepage-d7.demo.weebpal.com/#panel-second-wrapper .
GalleryController.php
public function gallery()
{
$galleries = Gallery::whereNotNull('image')->latest()->paginate(25);
$catCommittee = Category::where('parent_id',16)->get();
$categories = Category::where('parent_id', 42)->get();
return view('Home.galleries', compact('galleries','catCommittee', 'categories'));
}
galleries.blade.php
<div class="container">
<h2 class="mt-3 mb-3">{{ __('message.menu.galleries') }}</h2>
<div class="row">
<div class="container-fluid" style="margin-top:20px;">
<div class="row">
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
#foreach($categories as $category)
<li class="nav-item">
<a class="nav-link" id="isotope-{{ $category->id }}-tab" data-toggle="pill" href="#isotope-{{ $category->id }}" role="tab" aria-controls="isotope-{{ $category->id }}" aria-selected="false">{{ $category->name }}</a>
</li>
#endforeach
</ul>
</div><hr noshade style="margin-top:-20px;">
<div class="container grid">
<div class="tab-content" id="pills-tabContent">
#foreach($categories as $key=>$category)
<?php $ok = false;?>
#foreach($category->galleries as $key=>$gallery)
<?php $ok = true;?>
#if(count($category->galleries) == 1 || $key == 0)
<div class="tab-pane fade" id="isotope-{{ $gallery->pivot->category_id }}" role="tabpanel" aria-labelledby="isotope-{{ $gallery->pivot->category_id }}-tab">
#endif
<div class="Portfolio">
<a href="#!">
<img class="card-img" src="{{ $gallery->image }}" alt="">
</a>
<div class="desc">{{ $gallery->title }}</div>
</div>
#if(count($category->galleries) == 1 || count($category->galleries) == ++$key)
</div>
#endif
#endforeach
#if(!$ok)
<div class="tab-pane fade" id="isotope-{{ $category->id }}" role="tabpanel" aria-labelledby="isotope-{{ $category->id }}-tab"></div>
#endif
#endforeach
</div>
</div>
</div>
</div>
</div>
I tried show isotope for my site but was not successful.
ajax
<script src="https://unpkg.com/isotope-layout#3/dist/isotope.pkgd.min.js"></script>
<script>
$('.nav-item .nav-link').trigger('click');
$('.nav-item .nav-link').on('click', function (e) {
e.preventDefault();
var id = $(this).attr('id');
$('#pills-tabContent').isotope({ filter: '#'+id });
})
</script>
I have a search function and I want to add a where condition for results.
Here is my view
#foreach($users as $user)
<li class="col-sm-4 col-xs-6 md-margin-bottom-30">
<div class="team-img">
#if((isset($user['profile_picture'])) && !empty($user['profile_picture']))
#if($user['facebook_id'] == 0)
<?php $img = "thumbnail/".$user['profile_picture']; ?>
#if(#getimagesize($img))
<img class="img-responsive profile-img margin-bottom-20" src="{{ url('ass/263/255?'.$img) }}" alt="">
#else
<?php $img = "assets/img/team/img10-md.jpg"; ?>
<img class="img-responsive" src="{{ url('ass/263/255?'.$img) }}" alt="">
#endif
#else
<?php $img = $user['profile_picture']; ?>
#if(#getimagesize($img))
<img class="img-responsive profile-img margin-bottom-20" src="{{ url('ass/263/255?'.$img) }}" alt="" >
#else
<?php $img = "assets/img/team/img10-md.jpg"; ?>
<img class="img-responsive" src="{{ url('ass/263/255?'.$img) }}" alt="">
#endif
#endif
#else
<?php $img = "assets/img/team/img10-md.jpg"; ?>
<img class="img-responsive" src="{{ url('ass/263/255?'.$img) }}" alt="">
#endif
<ul class="social-icons social-icons-color social-cu-icons" style="display:none;">
<div class="social-cu">
<li class="facebook_share share_link" link="{{ url('') }}/{{ $user['username'] }}" name="{{ $user['username'] }}">
</li>
<li class="google_share share_link" link="{{ url('') }}/{{ $user['username'] }}" name="{{ $user['username'] }}">
</li>
<li class="twitter_share share_link" link="{{ url('') }}/{{ $user['username'] }}" name="{{ $user['username'] }}">
</li>
<li class="whatapp_share share_link" link="{{ url('') }}/{{ $user['username'] }}" name="{{ $user['username'] }}">
<img class="img-responsive social_whatsapp" src="{{ asset('/assets/img/icons/social/Whatsapp.png') }}" alt="">
</li>
</div>
</ul>
<ul>
#if(Sentinel::check())
#if(!in_array($user['id'], $invitation))
<li class="sendinvitation" value="{{ $user['id'] }}" id="sendinvitation">
<a href="javascript:void(0)">
<i class="icon-custom icon-sm rounded-x fa fa-user-plus {{ $user['id'] }} " style="border-radius: 4px !important"></i>
</a>
</li>
#endif
#else
<li class="sendinvitation1" value="{{ $user['id'] }}" id="sendinvitation">
<a href="javascript:void(0)" onClick="return loginConf();">
<i class="icon-custom icon-sm rounded-x fa fa-user-plus {{ $user['id'] }} " style="border-radius: 4px !important"></i>
</a>
</li>
#endif
#if(Sentinel::check())
<li class="send-contact-message" data-username="{{ $user['username'] }}" data-user-id="{{ $user['id'] }}">
<i class="icon-custom icon-sm rounded-x fa fa-paper-plane-o" style="border-radius: 4px !important"></i>
</li>
#else
<li class="send-contact-message1" data-user-id="{{ $user['id'] }}">
<i class="icon-custom icon-sm rounded-x fa fa-paper-plane-o" style="border-radius: 4px !important"></i>
</li>
#endif
<li class="share-link"></i></li>
</ul>
</div>
<h3 style="margin-top: 20px !important;text-transform: none"><a href="{{ url('') }}/{{ $user['username'] }}">
#if($user['role'][0]['slug'] == "organizations")
<i style="font-size: 11px" class="icon-hotel-restaurant-172 u-line-icon-pro fa- fa-lg"></i>
#else
<i style="font-size: 11px" class="icon-user"></i>
#endif
{{ $user['username'] }} </a></h3><p>
<strong><i class="icon-real-estate-020 u-line-icon-pro"></i> : </strong>{{ $user['country']['country'] }} <span class="{{ $user['country']['flag'] }}"></span><br>
#if(!empty($user['role']))
#if($user['role'][0]['slug'] == "organizations")
<strong><i class="icon-screen-tablet fa-" aria-hidden="true"></i> : </strong>{{ $user['industry']['industry'] }}<br>
#endif
#if($user['role'][0]['slug'] == "individuals")
<?php $career_path = array_reverse($user['career_path']); ?>
#if($career_path)
<strong><i class="icon-screen-tablet fa-" aria-hidden="true"></i> : </strong>{{ $career_path[0]['industry']['industry'] }}<br>
#else
<strong><i class="icon-screen-tablet fa-" aria-hidden="true"></i> : </strong><br>
#endif
#endif
#else
<strong><i class="icon-screen-tablet fa-" aria-hidden="true"></i> : </strong><br>
#endif
#if(!empty($user['role']))
#if($user['role'][0]['slug'] == "organizations")
<strong><i class="icon-frame fa-" aria-hidden="true"></i> : </strong>{{ $user['organization_type']['organization_type'] }}<br>
#elseif($user['role'][0]['slug'] == "individuals")
<?php $career_path = array_reverse($user['career_path']); ?>
#if($career_path)
#foreach($career_path as $careerpath)
<!-- <strong>Company:</strong>{{ $careerpath['company'] }}<br> -->
<strong><i class="icon-speedometer fa-" aria-hidden="true"></i> : </strong>{{ $careerpath['functions']['function'] }}
#break;
#endforeach
#else
<strong><i class="icon-speedometer fa-" aria-hidden="true"></i> : </strong>
#endif
#endif
#else
<strong><i class="icon-speedometer fa-" aria-hidden="true"></i> : </strong>
#endif
</p>
<br>
</li>
#endforeach
$users = User::with('country','industry','organization_type','career_path','career_path.industry','career_path.department','career_path.functions','role');
$private = DB::table('privacy_settings')->get();
$private = (array) $private;
$data['users'] = $users->orderBy('id', 'DESC')->skip($offset)->take($perPage)->get()->toArray();
So, with dd($private) I have an array with multiple values, but I need only value city. In my view I'm using a foreach function, and {{$private->city}} to display value of every user.
Now, I want to add something like that in $data['users'], if it's possible : where($private->city, '!=', 1) . That's should display only contacts with $private->city == 0 .
dd($data['users'])
array:12 [▼
0 => array:60 [▼
"id" => 559
"customer_stripe_id" => null
"username" => "Mihail22"
"name" => "Mihail22"
"first_name" => null
"last_name" => null
"dob" => "0000-00-00"
"city" => ""
"telephone" => ""
"address" => ""
"website1" => ""
Here city is the name of city
dd($private)
array:297 [▼
0 => {#954 ▼
+"id": "142"
+"user_id": "559"
+"email": "1"
+"website": "1"
+"phone": "1"
+"address": "1"
+"city": "1"
+"current_job": "1"
+"job_history": "1"
+"education_history": "1"
+"career_solutions": "1"
+"profile_updates": "0"
+"contacts_list": "1"
+"groups": "1"
}
1 => {#953 ▶}
Here city is for privacy ( 1 - public, 0 - private )
You can build a query that selects the user_id of all privacy_settings where city == 0. You can then add a WHERE IN to the $users query to limit it to only users with those ids by passing in the previous query being built:
$user_ids_query = DB::table('privacy_settings')
->where('city', 0)
->select('user_id');
$data['users'] = $users->whereIn('id', $user_ids_query)
->orderBy('id', 'DESC')
->skip($offset)
->take($perPage)
->get()
->toArray(); // to match what you expect
This looks like a good candidate for setting up a relationship and using what is available that way as well.
Try
$private = DB::table('privacy_settings')->where("city",0)->get();
print_r($private);
$data['users'] = $users->where("city",0)->orderBy('id', 'DESC')->skip($offset)->take($perPage)->get()->toArray();
print_r($data['users']);
How Can I set a limit for "Recent News" posts? I wanted to set a limit for 4, but it's showing all of them. As a bonus insert a "SEE ALL NEWS" button in the end...
I have this:
#foreach($news as $news)
#php
$news_img = ($news['anexo'] ? get_image_small_url($news['anexo']['ane_arquivo']) : '');
$news_img = $news_img ?: 'http://placehold.it/300.jpg?text=%20';
$news_txt = (empty($news['pub_resumo']) ? $news['pub_conteudo'] : $news['pub_resumo']);
#endphp
<div class="media media-thumb">
#if($news_img)
<div class="media-left">
<a href="{{ url('/news/'.$news['post_id']) }}">
<img class="media-object" src="{{ $news_img }}" alt="{{ $news['pub_titulo'] }}">
</a>
</div>
#endif
<div class="media-body">
<div class="post-meta">
<span class="published">{{ date('d/m/Y', strtotime($news['pub_data_cadastro'])) }}</span>
#if(!empty($news['categories']))
<span class="categories">{{ join(', ', array_column($news['categories'], 'tcp_nome')) }}</span>
#endif
</div>
<h4 class="media-heading">
{{ $news['title'] }}
</h4>
<p>{{ get_excerpt($news_txt, 180) }}</p>
</div>
</div>
#endforeach
The controller
$news = Publicacao::select('publicacao_id', 'pub_titulo', 'pub_conteudo', 'pub_resumo', 'pub_data_cadastro', 'anexo_id')
->with(['categorias', 'anexo'])
->where('pub_tipo', 'NOT')
->where('pub_status', 'PUB')
->limit(5)
->orderBy('pub_data_cadastro', 'desc')
->get();
$this->data['news'] = $news->toArray();
return view('site.home', $this->data);
}
Cheers!