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
- Laravel URL validation not working
- Docker important commands to run laravel application with docker
- Laravel insert query not working
- Submit form without CSRF token in Laravel
- How to get last year records count with month wise in Laravel
- How to create belongstomany relation using custom name on custom pivot table
- Command to create MySQL Docker image and access the MySQL command-line interface (CLI) within a running Docker container
- Laravel change date format
- Define variable and use in Laravel controller method
- Route group with URI prefix using middleware and route name prefixes
- Calculate age from date of birth in Laravel
- Laravel order by date not working
- How to get column names from table in Laravel
- Create project factory and seed data in laravel
- Get previous date data in laravel
- Use withCount() to get total number of records with relationship
- Use of undefined constant laravel
- Redirect to another view from controller in laravel
- How to add class to tr in table using foreach in laravel
- How to get database name in Laravel 9 ?
- How to call controller function from view in Laravel
- How to get all route list
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- Php artisan make model, factory, migration and controller in single command
- SQLSTATE[23000]: Integrity constraint violation: 1022 Can't write; duplicate key in table