2

CONTROLLER

public function index() {
    $users = User::all(); // Is there a way to chain it with the except method or sth like that
    return View::make('distributors.index')->with('users',$users);
}

GOAL

I want to query all of my users table, but one.

I want to list all the user(s) for my client, but I want to hide my self.

Question

How do I do that ? Am I approaching it in the right way ?

Feel free to give me any suggestions for improvement.

4
  • 1
    I'm not too familiar with laravel, but could you use something like User::Where('id', '!=', '1')->get(); The 1 would be your user id Commented Nov 18, 2014 at 21:57
  • Exactly what @VincentMatte is the correct answer. Commented Nov 18, 2014 at 23:22
  • 1
    @VincentMatte : You're right !! Commented Nov 19, 2014 at 15:04
  • here you can find better solution stackoverflow.com/a/32627797/7373178 Commented Sep 14, 2018 at 10:23

1 Answer 1

10

If you mean except currently logged in user, then do:

$users = User::where('id', '!=', Auth::id())->get();
Sign up to request clarification or add additional context in comments.

1 Comment

Not exactly, but very close.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.