Laravel Eloquent ORM:访问表的特定单元格


Laravel Eloquent ORM: Accessing a specific cell of table

我正在尝试访问表的特定单元格。我必须在Laravel Eloquent ORM中运行以下查询:

SELECT email FROM users WHERE id=$id;

以下是我迄今为止所做的:

$user=new users;//users is model
$user=users::where('email',$email)
   ->where('password',$pass)
   ->get();
$mail=$user->email;

我遇到了这个错误:

HomeController.php中的ErrorException第52行:未定义的属性:Illuminate''Database''Eloquent''Collection::$email-

有什么帮助吗?

我想我会把这个作为其他人的答案——

->get()返回集合,->first()返回模型。

->first()替换->get(),或者执行$user->first()->email