samedi 6 mai 2023

Query Builder Spefic Query

i want to show only the contacts that the user is messaging, I don't want the people that the user has not messaged to appear. How can i fix this?

DATABASE: DATABASE PHOTO

Query Command:

 public static function otherUserData($user_id)

  {

    $value = DB::table('users')

    ->select(['*', DB::raw('MAX(conver_date) AS lastConver')])

    ->leftJoin('conversation', function ($join) use ($user_id) {

        $join->on('conversation.conver_seller_id', '=', 'users.id')

            ->on('conversation.conver_user_id', '=', DB::raw($user_id))

            ->orOn('conversation.conver_seller_id', '=', DB::raw($user_id))

            ->on('conversation.conver_user_id', '=', 'users.id'); 

    })

    ->where('user_type', '!=', 'admin')

    ->where('id', '!=', $user_id)

    ->where('drop_status', '=', 'no')

    ->orderBy('lastConver', 'desc')

    ->groupBy('id')

    ->get(); 



return $value;

  }

I will be glad if you help me thank you.



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

Aucun commentaire:

Enregistrer un commentaire