📜  laravel 模型与模型中的路由绑定 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:11.657000             🧑  作者: Mango

代码示例1
/**
 * Retrieve the model for a bound value.
 *
 * @param  mixed  $value
 * @param  string|null  $field
 * @return \Illuminate\Database\Eloquent\Model|null
 */
public function resolveRouteBinding($value, $field = null)
{
    return $this->where('name', $value)->firstOrFail();
}