Laravel 7.x:fresh 和 refresh 方法的区别?

Gur*_*ngh 2 laravel eloquent eloquent-relationship laravel-7

在阅读 Laravel 文档时,我遇到了一个名为freshand的方法,该方法refresh基于 Eloquent 模型。请解释它们之间的主要区别?我很难理解这些。

lag*_*box 6

这是该refresh方法的注释Illuminate\Database\Eloquent\Model

/**
 * Reload the current model instance with fresh attributes from the database.
 *
 * @return $this
 */
public function refresh()
Run Code Online (Sandbox Code Playgroud)

这是一个fresh

/**
 * Reload a fresh model instance from the database.
 *
 * @param  array|string  $with
 * @return static|null
 */
public function fresh($with = [])
Run Code Online (Sandbox Code Playgroud)

refresh将刷新当前模型实例(包括关系)。fresh将从数据库中获取模型的新实例并返回它。