gpt4 book ai didi

php - 如何在 Laravel 4 中查询除一个以外的所有内容?

转载 作者:搜寻专家 更新时间:2023-10-30 21:46:44 24 4
gpt4 key购买 nike

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);
}

目标

我想查询我的所有用户表,但只有一个。

我想为我的客户列出所有用户,但我想隐藏我自己。

问题

我该怎么做?我是否以正确的方式处理它?<​​/p>

请随时给我任何改进建议。

最佳答案

如果你的意思是除了当前登录的用户,那么做:

$users = User::where('id', '!=', Auth::id())->get();

关于php - 如何在 Laravel 4 中查询除一个以外的所有内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27004438/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com