8000 Eloquent ::all() returns a Collection object from an empty table · Issue #79 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

Eloquent ::all() returns a Collection object from an empty table #79

@driesvints

Description

@driesvints

I might be doing something wrong here but I followed the very basic example from the docs.

I'm simple retrieving all the users from the database which is empty but I get a Collection object back with 2 protected variables so my result isn't really 'empty'.

PHP code in the Controller:

class UsersController extends BaseController {

    public function index()
    {
        $users = User::all();
        var_dump($users);

        return View::make('admin.users.index')->with('users', $users);
    }

}

Response from var_dump:

object(Illuminate\Database\Eloquent\Collection)#130 (2) { ["items":protected]=> array(0) { } ["dictionary":protected]=> array(0) { } }

This means that I can't do the following in a Blade view because it will always pass the if statement:

@if($users)

The user model is pretty basic:

class User extends Eloquent {

    protected $table = 'users';

}

Any ideas? :-/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0