
get all users except the followings users in overtrue laravel-follow
get all users except the followings users in overtrue laravel-follow
Through many examples, we will learn how to resolve the "get all users except the followings users in overtrue laravel-follow".
You can get all the users except the followings users in overtrue laravel-follow package. It is one of the most common case in which you have to show the users list on your page to whom you did not follow yet.-
Get all users list except the followings users in overtrue laravel-follow package
$user = Auth::user(); $users = User::select('id', 'name', 'image')->whereNotIn('id', $user->followings->pluck('id'))->where('id', '<>', $user->id)->take(4)->inRandomOrder()->get(); return view('user')->with(compact('users'));
This code snippet will help you to get the all users who you did not follow yet. It will get ids from the user's table using the followings() method and avoid the user records using the whereNotIn() method and also the record of the logged-in user and return to view file.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to create pivot table in laravel using migration
- How to create and run user seeder in laravel
- How to fill a column automatically while creating records in Laravel
- Delete file from amazon s3 bucket using Laravel
- Print query in laravel
- Define variable and use in Laravel controller method
- How to get last record from object collection in laravel
- How to display pivot table column value in laravel
- Retain selected value of select box in Laravel
- How to pass variable from controller to model in Laravel
- Generate random string lowercase in Laravel
- How to validate URL with https using regex in laravel
- How to check relationship is loaded or not in Laravel
- How to insert ckeditor data into database in Laravel?
- Get current month records in laravel 7/8
- Insert current date time in a column using Laravel
- The POST method is not supported for this route. Supported methods: PUT.
- FirstOrCreate() Not Inserting Model
- Convert input array to comma-separated string in laravel controller
- Call to a member function getRelationExistenceQuery() on array in Laravel
- How to add class to tr in table using foreach in laravel
- Class App\Http\Controllers\Admin\UserController Does Not Exist
- Composer\Exception\NoSslException
- SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'user_id'
- How to insert dynamic value to additional column in pivot table in laravel