vendredi 28 septembre 2018

How can i set condition if one column has NULL value then don't show results

Thas my controller file

public function myFriends()
        {

Logged user

$uid = Auth::user()->id;

Getting result from friendships table

            $friends1 = DB::table('friendships')
                ->leftJoin('users', 'users.id','=', 'friendships.user_requested') // whos is not loogged in but send the request
                ->where('status', 1)
                ->join('profiles', 'profiles.user_id', '=', 'friendships.requester')
                ->where('requester', $uid)
                ->get();

I have one more array friends2 i just skip that

            $friends = array_merge($friends1->toArray(), $friends2->toArray());
            return view('profile.friends', compact('friends'));

My view page

@foreach($friends as $uList)
*if in there column value has NULL then don't show follwers*

                      @if($uList->followingeach == NULL )
                       {
                            <?php echo Auth::user()->name .'You dont have follwers' ?>
                        }
                        @else
                        {
                            <?php echo Auth::user()->name .'Yes You have follwers' ?>
                        }
                        @endif

My DB columns

enter image description here



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2xW4MWg
via IFTTT

Aucun commentaire:

Enregistrer un commentaire