Search code examples
phplaravellaravel-9

Laravel 9 - Read/Get Request


I'm beginning a full project with Laravel 9, I'm creating a users management page.

I would like to read all informations from 'users' table except the password.

    public function AffichageGestion()
    {
        $users = User::all();
        return view('usersManagement.userManagement')->with('users', $users);
    }

This is my code for the moment, I select all informations but I don't want this. I want all informations except the password. How can I do that please ?

Thank you :)


Solution

  • Also, you can do like this.

    public function AffichageGestion()
    {
        $users = User::all([ 'name', 'email']); // except password
        return view('usersManagement.userManagement')->with('users', $users);
    }