
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
- Undefined property: stdClass::$title
- SQLSTATE[23000]: Integrity constraint violation: 1022 Can't write; duplicate key in table
- How to Access Array in blade laravel
- Convert multidimensional array to single array in Laravel
- External link not working in laravel blade
- Route prefix with auth middleware in laravel
- How to get CSRF token in laravel controller
- How to add active class to menu item in laravel
- Target class [admin] does not exist.
- How to pass variable from controller to model in Laravel
- The use statement with non-compound name 'DB' has no effect
- Datetime field in Laravel migration
- The POST method is not supported for this route. Supported methods: PUT.
- Submit form without CSRF token in Laravel
- Create project table with model and migration
- Class App\Http\Controllers\Admin\UserController Does Not Exist
- Method Illuminate\Database\Eloquent\Collection::appends does not exist
- How to send email in laravel
- How to display 1 day ago in comments in laravel view
- SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist
- How to check duplicate entry in laravel
- Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() must be of the type string or null, object given
- Laravel specific table Migration
- Calculate age from date of birth in Laravel
- Property [user] does not exist on this collection instance