Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@driesvints

Description

@driesvints
Issue body actions

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.