Php 雄辩模型的创建方法在哪里?

Php 雄辩模型的创建方法在哪里?,php,laravel,laravel-5,Php,Laravel,Laravel 5,可以通过以下方式在Laravel中创建每个模型: 在Laravel 5.6中,在哪里可以找到该方法的代码 我查看了类illumb\Database\elount\Model,但找不到create方法 我还检查了所有的特征(从HasAttributes到GuardsAttributes),但是我也没有在那里找到create方法 由于类model没有扩展任何其他类,我有点困惑create方法隐藏在哪里。雄辩的模型使用神奇的方法(\uu调用,\uu调用静态)将调用传递给雄辩的构建器类。因此,Mode

可以通过以下方式在Laravel中创建每个模型:

在Laravel 5.6中,在哪里可以找到该方法的代码

我查看了类
illumb\Database\elount\Model
,但找不到
create
方法

我还检查了所有的特征(从
HasAttributes
GuardsAttributes
),但是我也没有在那里找到
create
方法


由于类
model
没有扩展任何其他类,我有点困惑
create
方法隐藏在哪里。

雄辩的模型使用神奇的方法(\uu调用,\uu调用静态)将调用传递给雄辩的构建器类。因此,Model::create()实际上是将调用传递给Builder::create()方法

但是,如果您研究该方法,它基本上与调用相同:

$model = new Model($attributes);
$model->save();
通过passthrough将(Query)Builder混合使用,您可以使用查询方法,如
Model::where()
检查以下文件


PATH\u TO\u PROJECT/vendor/laravel/framework/src/illusted/Database/elount/Builder.php

您可以在github中找到它


你是说这个?你的问题到底是什么?因为接受的答案不能回答您的问题。@NeelBhanushali,模型类上没有create方法,这就是为什么我解释了它是如何传递给Builder类的。这应该能回答问题。@Devon我的错,我以为他需要文件位置。你解释得很好,而其他人都给出了位置。
$model = new Model($attributes);
$model->save();
public function create(array $attributes = [])
{
    return tap($this->newModelInstance($attributes), function ($instance) {
        $instance->save();
    });
}
/**
 * Save a new model and return the instance. Allow mass-assignment.
 *
 * @param  array  $attributes
 * @return \Illuminate\Database\Eloquent\Model|$this
 */
public function forceCreate(array $attributes)
{
    return $this->model->unguarded(function () use ($attributes) {
        return $this->newModelInstance()->create($attributes);
    });
}