Laravel 紧急加载在L4中不起作用

Laravel 紧急加载在L4中不起作用,laravel,laravel-4,eloquent,eager-loading,Laravel,Laravel 4,Eloquent,Eager Loading,我有以下表格: 用户 Schema::create('users', function(Blueprint $table) { $table->increments('id'); $table->string('username', 30); $table->string('email')->unique(); $table->string('password', 60);

我有以下表格:

用户

    Schema::create('users', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('username', 30);
        $table->string('email')->unique();
        $table->string('password', 60);
        $table->string('remember_token')->nullable();
        $table->timestamps();
    });
    Schema::create('organisations', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('name')->unique('name');
        $table->integer('owner_id')->unsigned()->index()->nullable();
        $table->foreign('owner_id')->references('id')->on('users');
        $table->timestamps();
    });
组织机构

    Schema::create('users', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('username', 30);
        $table->string('email')->unique();
        $table->string('password', 60);
        $table->string('remember_token')->nullable();
        $table->timestamps();
    });
    Schema::create('organisations', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('name')->unique('name');
        $table->integer('owner_id')->unsigned()->index()->nullable();
        $table->foreign('owner_id')->references('id')->on('users');
        $table->timestamps();
    });
我的组织结构如下雄辩:

class Organisation extends Eloquent {

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function owner()
    {
        return $this->belongsTo('User', 'owner_id', 'id');
    }

}
我正在尝试在我的控制器中使用
elount
ORM的
Eager load
功能:

public function index()
{
    return View::make('organisations.index')
        ->with('organisations', Organisation::with('user')->all());
}
执行此操作时,会出现以下异常错误:

调用未定义的方法illumb\Database\Query\Builder::all() 你知道为什么这样不行吗?我是否错误地使用了即时加载?

all()
Model
类中的静态方法,只能这样使用:
Model::all()

您需要使用
get()
来执行查询

Organisation::with('owner')->get();

谢谢这几乎奏效了。我需要的是:
organization::with('owner')->get()作为我的
归属关系在
organization
模型的
owner()
方法中定义。A是。老实说,我根本没看你的亲戚。我只看到了错误和你的电话,知道问题出在哪里;)