在逛论坛的过程中看到的。

    1. public function newInstance($attributes = [], $exists = false)
    2. {
    3. $model = new static((array) $attributes);
    4. $model->exists = $exists;
    5. $model->setConnection(
    6. $this->getConnectionName()
    7. );
    8. return $model;
    9. }

    注意

    1. $model = new static((array) $attributes);

    这里的 new static 相当于实例化当前模型,也就是会调用 __construct() 方法。