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

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

代码示例5
/**
 * 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();
}