我目前在制作显示每个用户的网站页面时遇到了麻烦,以便对其进行管理。
将显示用户的姓名,电子邮件,权限和链接以修改,重置密码并将其删除在其他页面上
我在控制器中为页面" manage-user":
创建了一个功能public function getManageUsers(){
$users = User::all();
var_dump($users);
return View::make('UsersManagement.manage-users')->with('users', '$users');
}
但是var_dump()的结果实际上是:
object(Illuminate\Database\Eloquent\Collection)[163]
protected 'items' =>
array (size=3)
0 =>
object(User)[159]
protected 'table' => string 'users' (length=5)
protected 'hidden' =>
array (size=2)
...
protected 'connection' => null
protected 'primaryKey' => string 'id' (length=2)
protected 'perPage' => int 15
public 'incrementing' => boolean true
public 'timestamps' => boolean true
protected 'attributes' =>
array (size=9)
...
protected 'original' =>
array (size=9)
...
protected 'relations' =>
array (size=0)
...
protected 'visible' =>
array (size=0)
...
protected 'appends' =>
array (size=0)
...
protected 'fillable' =>
array (size=0)
...
protected 'guarded' =>
array (size=1)
...
protected 'dates' =>
array (size=0)
...
protected 'touches' =>
array (size=0)
...
protected 'observables' =>
array (size=0)
...
protected 'with' =>
array (size=0)
...
protected 'morphClass' => null
public 'exists' => boolean true
这是模型,如果它有帮助:
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
}
我不明白问题所在,因为我总是使用这行代码来检索数据库的每个数据,而且它总是使用DB的索引。
我真的迷失了这种情况,不知道该怎么做。 欢迎任何帮助。 提前谢谢。
达明