@tisuchi
Hi ,
This is my problem scenario :
i have one controller name userprofile controller here i call method name index() and this is my single profile view controller
this is my single profile route
Route::get('user/user-profile-view/{id}', 'User\UserprofileController@index');
i have many kind of record set - like .
contact list # proposal list # favorite list # trash list #all user list # active user list
so when record list show then click single profile view button . when action button click
<a href="{{ url('user/user-profile-view',$userInfo->user_id) }}">
there are many different type record set for click single view profile ...
in this moment i want this previous and next record .
its good news i follow your instruction and complete next previous issue . but new thing is , how to do for all kind of different different type record set from different different controller .
now i am direct call all variable from userprofile controller
that's why arise new issue if i have record set for one quarry contact list controller then my previous and next data show ... but if some one try to another single page from other controller like favorite controller then show
Trying to get property 'id' of non-object
this is my quarry
$userID = ContactRequest::where('contact_receiver_user_id', $id)->where('mode', 1)->where('contact_request.contact_sender_user_id', auth()->user()->id)->select('id')->first()->id;
// dd($userID);
$next = ContactRequest::join('user_infos', 'user_infos.user_id', 'contact_request.contact_receiver_user_id')
->where('contact_request.contact_sender_user_id', auth()->user()->id)
->whereIn('contact_request.contact_receiver_user_id', [DB::raw("SELECT id FROM active_users_id")])
->where('mode', 1)
->where('contact_request.id', '<', $userID)
->orderBy('contact_request.contact_date', 'desc')
->first();
$previous = ContactRequest::join('user_infos', 'user_infos.user_id', 'contact_request.contact_receiver_user_id')
->where('contact_request.contact_sender_user_id', auth()->user()->id)
->whereIn('contact_request.contact_receiver_user_id', [DB::raw("SELECT id FROM active_users_id")])
->where('mode', 1)
->where('contact_request.id', '>', $userID)
->orderBy('contact_request.contact_date', 'desc')
->first();
// dd($previous);
$first = ContactRequest::join('user_infos', 'user_infos.user_id', 'contact_request.contact_receiver_user_id')
->where('contact_request.contact_sender_user_id', auth()->user()->id)
->whereIn('contact_request.contact_receiver_user_id', [DB::raw("SELECT id FROM active_users_id")])
->where('mode', 1)
->orderBy('contact_request.contact_date', 'desc')
->first();
$last = ContactRequest::join('user_infos', 'user_infos.user_id', 'contact_request.contact_receiver_user_id')
->where('contact_request.contact_sender_user_id', auth()->user()->id)
->whereIn('contact_request.contact_receiver_user_id', [DB::raw("SELECT id FROM active_users_id")])
->where('mode', 1)
->orderBy('contact_request.contact_date', 'desc')
->get()
->last();
its error for this code
$userID = ContactRequest::where('contact_receiver_user_id', $id)->where('mode', 1)->where('contact_request.contact_sender_user_id', auth()->user()->id)->select('id')->first()->id;
how to condition use for this quarry ?
or do you have others way to solve this kind problem-
this is my blade next previous action button
<ul class="pagination pull-right profile_pag">
@if($first->contact_receiver_user_id != $id)
<li>
<a class="btn btn-circle btn-xs" href="{{url('user/user-profile-view',$first->contact_receiver_user_id)}}">
<i class="fa fa-angle-left"></i> First
</a>
</li>
@endif
@if(!empty($previous->contact_receiver_user_id))
<li>
<a class="btn btn-circle btn-xs" href="{{url('user/user-profile-view',$previous->contact_receiver_user_id)}}">
<i class="fa fa-angle-left"></i> Prev
</a>
</li>
@endif
@if(!empty($next->contact_receiver_user_id))
<li>
<a class="btn btn-circle btn-xs" href="{{url('user/user-profile-view',$next->contact_receiver_user_id)}}">
Next<i class="fa fa-angle-right"></i>
</a>
</li>
@endif
@if($last->contact_receiver_user_id != $id)
<li>
<a class="btn btn-circle btn-xs" href="{{url('user/user-profile-view',$last->contact_receiver_user_id)}}">
<i class="fa fa-angle-right"></i> Last
</a>
</li>
@endif
</ul>
thank you