samedi 6 mai 2023

Query Builder Skip Blank messages

I don't want users to whom the user has not sent or received messages before appear in the list, how can I fix this? Currently all users are listing.

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.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire