函数参考
约 12335 字大约 41 分钟
2026-10-13
统计范围:项目的控制器、中间件、数据库迁移、数据填充及 Web/API 路由代码。按当前代码实际调用整理 PHP 内置函数、Laravel 方法、全局辅助函数及门面方法,共 51 个条目;同名方法因所属对象和参数不同分别列出。
源码依据:项目已安装的 Laravel 12.68.0 和 PHP 8.2.12。每个条目给出函数作用及参数表;门面追踪到实际实现。prefix、middleware 是动态方法,实际分发机制在说明中列出。
“无(必传)”表示形参没有默认值,不等于默认 null。展开内容保留 Laravel 原始注释、原始声明和参数名/默认值表,中文含义根据实现整理。折叠使用 VuePress 格式 ::: details 点击展开,以 ::: 结束。
一、PHP 内置函数
md5
计算字符串的 MD5 摘要;项目用于保存/比对密码、根据用户名生成 token,以及 Seeder 的初始密码。该函数是 PHP 内置实现,vendor 没有它的 PHP 定义文件。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$string | 无(必传) | 原始密码或用户名;生成密码摘要或登录 token。 |
$binary | false | 是否返回 16 字节二进制摘要;默认 false,项目得到 32 位十六进制字符串。 |
点击展开:原始注释、声明及完整参数信息
PHP 内置函数没有可提取的 Laravel/PHP 用户态源码注释;以下签名和默认值由本机 PHP Reflection 提取。
原始声明:
md5(string $string, bool $binary = false)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$string | string | 未提供 @param | 无(必传) | 原始密码或用户名;生成密码摘要或登录 token。 |
$binary | bool | 未提供 @param | false | 是否返回 16 字节二进制摘要;默认 false,项目得到 32 位十六进制字符串。 |
date
按格式输出日期时间;take 中分别传入 Y-m-d、H:i:s。未传时间戳时使用当前时间,时区取执行时 PHP 配置。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$format | 无(必传) | 日期时间格式;本项目使用 Y-m-d 与 H:i:s。 |
$timestamp | null | Unix 时间戳;默认 null,表示当前时间。 |
点击展开:原始注释、声明及完整参数信息
PHP 内置函数没有可提取的 Laravel/PHP 用户态源码注释;以下签名和默认值由本机 PHP Reflection 提取。
原始声明:
date(string $format, ?int $timestamp = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$format | string | 未提供 @param | 无(必传) | 日期时间格式;本项目使用 Y-m-d 与 H:i:s。 |
$timestamp | ?int | 未提供 @param | null | Unix 时间戳;默认 null,表示当前时间。 |
explode
按分隔符拆分字符串;Auth2 把 ADMIN|WORKER|USER 一类角色字符串以竖线拆成数组。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$separator | 无(必传) | 拆分分隔符;本项目为竖线字符。 |
$string | 无(必传) | 允许角色字符串;例如 ADMIN|WORKER|USER。 |
$limit | PHP_INT_MAX | 结果数量限制;默认 PHP_INT_MAX,可理解为不额外限制拆分数量。 |
点击展开:原始注释、声明及完整参数信息
PHP 内置函数没有可提取的 Laravel/PHP 用户态源码注释;以下签名和默认值由本机 PHP Reflection 提取。
原始声明:
explode(string $separator, string $string, int $limit = PHP_INT_MAX)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$separator | string | 未提供 @param | 无(必传) | 拆分分隔符;本项目为竖线字符。 |
$string | string | 未提供 @param | 无(必传) | 允许角色字符串;例如 ADMIN|WORKER|USER。 |
$limit | int | 未提供 @param | PHP_INT_MAX | 结果数量限制;默认 PHP_INT_MAX,可理解为不额外限制拆分数量。 |
in_array
判断值是否存在于数组;Auth2 检查用户 type 是否属于允许角色数组,当前未传 strict,默认采用非严格比较。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$needle | 无(必传) | 要搜索的值;项目为用户 type。 |
$haystack | 无(必传) | 待搜索数组;项目为 explode 得到的允许角色列表。 |
$strict | false | 是否同时严格比较值和类型;默认 false,本项目未覆盖。 |
点击展开:原始注释、声明及完整参数信息
PHP 内置函数没有可提取的 Laravel/PHP 用户态源码注释;以下签名和默认值由本机 PHP Reflection 提取。
原始声明:
in_array(mixed $needle, array $haystack, bool $strict = false)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$needle | mixed | 未提供 @param | 无(必传) | 要搜索的值;项目为用户 type。 |
$haystack | array | 未提供 @param | 无(必传) | 待搜索数组;项目为 explode 得到的允许角色列表。 |
$strict | bool | 未提供 @param | false | 是否同时严格比较值和类型;默认 false,本项目未覆盖。 |
二、Laravel 辅助函数与响应方法
Routing\ResponseFactory::json
创建 JSON HTTP 响应;由 response()->json(...) 调用,项目默认成功状态 200,也显式设置失败或确认响应状态。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$data | [] | 要编码为 JSON 的响应内容;项目包含 code、message 以及可选 data。 |
$status | 200 | HTTP 状态码;根据函数可为 JSON 响应状态或重定向状态。 |
$headers | [] | 响应头键值数组;项目省略,使用空数组。 |
$options | 0 | JSON 编码选项位掩码;默认 0,项目未覆盖。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new JSON response instance.
*
* @param mixed $data
* @param int $status
* @param array $headers
* @param int $options
* @return \Illuminate\Http\JsonResponse
*/原始声明:
public function json($data = [], $status = 200, array $headers = [], $options = 0)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$data | 未声明 | mixed | [] | 要编码为 JSON 的响应内容;项目包含 code、message 以及可选 data。 |
$status | 未声明 | int | 200 | HTTP 状态码;根据函数可为 JSON 响应状态或重定向状态。 |
$headers | array | array | [] | 响应头键值数组;项目省略,使用空数组。 |
$options | 未声明 | int | 0 | JSON 编码选项位掩码;默认 0,项目未覆盖。 |
response
获取响应工厂或创建普通响应;项目调用 response() 不传参数,因此返回 ResponseFactory,随后调用 json。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$content | null | 普通响应内容;项目 response() 不传任何参数,直接取得响应工厂。 |
$status | 200 | 普通响应 HTTP 状态码,默认 200;无实参 response() 返回工厂时此默认值不创建响应。 |
$headers | [] | 普通响应头数组;项目无实参调用 response(),随后在 json 中创建响应。 |
点击展开:原始注释、声明及完整参数信息
/**
* Return a new response from the application.
*
* @param \Illuminate\Contracts\View\View|string|array|null $content
* @param int $status
* @return ($content is null ? \Illuminate\Contracts\Routing\ResponseFactory : \Illuminate\Http\Response)
*/原始声明:
function response($content = null, $status = 200, array $headers = []): ResponseFactory|IlluminateResponse| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$content | 未声明 | \Illuminate\Contracts\View\View|string|array|null | null | 普通响应内容;项目 response() 不传任何参数,直接取得响应工厂。 |
$status | 未声明 | int | 200 | 普通响应 HTTP 状态码,默认 200;无实参 response() 返回工厂时此默认值不创建响应。 |
$headers | array | 未提供 @param | [] | 普通响应头数组;项目无实参调用 response(),随后在 json 中创建响应。 |
三、请求与验证方法
Validator::make → Factory::make
创建验证器实例;项目通过 Validator Facade 调用,验证注册、登录、预订、员工、桌位、取号、结账和鉴权输入。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$data | 无(必传) | 待验证数据数组;项目传入请求体或全部请求字段。 |
$rules | 无(必传) | 字段到验证规则的映射;决定字段必填、类型、长度、格式或唯一性等要求。 |
$messages | [] | 自定义错误消息;项目省略,使用验证器默认消息。 |
$attributes | [] | 自定义字段显示名称;用于错误消息,项目省略。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new Validator instance.
*
* @param array $data
* @param array $rules
* @param array $messages
* @param array $attributes
* @return \Illuminate\Validation\Validator
*/函数体原注释:
// The presence verifier is responsible for checking the unique and exists data
// for the validator. It is behind an interface so that multiple versions of
// it may be written besides database. We'll inject it into the validator.
// Next we'll set the IoC container instance of the validator, which is used to
// resolve out class based validator extensions. If it is not set then these
// types of extensions will not be possible on these validation instances.原始声明:
public function make(array $data, array $rules, array $messages = [], array $attributes = [])| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$data | array | array | 无(必传) | 待验证数据数组;项目传入请求体或全部请求字段。 |
$rules | array | array | 无(必传) | 字段到验证规则的映射;决定字段必填、类型、长度、格式或唯一性等要求。 |
$messages | array | array | [] | 自定义错误消息;项目省略,使用验证器默认消息。 |
$attributes | array | array | [] | 自定义字段显示名称;用于错误消息,项目省略。 |
Validation\Validator::fails
执行验证并返回是否失败;项目在失败时调用 ResponseController::failure。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
| 无 | 不适用 | 此函数没有声明参数。 |
点击展开:原始注释、声明及完整参数信息
/**
* Determine if the data fails the validation rules.
*
* @return bool
*/原始声明:
public function fails()| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
| 无 | 不适用 | 不适用 | 不适用 | 此函数没有声明参数。 |
Validation\Rule::in
构造值必须属于允许集合的验证规则;项目传入 A、B、C,限制 table_type。也支持多个实参,源码通过 func_get_args() 接收。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$values | 无(必传) | 允许值集合;本项目为 ["A","B","C"],构建桌型 in 验证规则。 |
点击展开:原始注释、声明及完整参数信息
/**
* Get an in rule builder instance.
*
* @param \Illuminate\Contracts\Support\Arrayable|\UnitEnum|array|string $values
* @return \Illuminate\Validation\Rules\In
*/原始声明:
public static function in($values)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$values | 未声明 | \Illuminate\Contracts\Support\Arrayable|\UnitEnum|array|string | 无(必传) | 允许值集合;本项目为 ["A","B","C"],构建桌型 in 验证规则。 |
Request::post
读取请求体参数;不传 $key 时返回请求体全部字段,项目用于注册、登录和预订验证。该方法读取 request 参数袋;正常 Laravel HTTP 请求构建时,JSON 请求体也会被放入该参数袋。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$key | null | 待读取字段名;null 表示返回该输入源的全部数据。 |
$default | null | 指定字段不存在时返回的备用值。 |
点击展开:原始注释、声明及完整参数信息
/**
* Retrieve a request payload item from the request.
*
* @param string|null $key
* @param string|array|null $default
* @return string|array|null
*/原始声明:
public function post($key = null, $default = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$key | 未声明 | string|null | null | 待读取字段名;null 表示返回该输入源的全部数据。 |
$default | 未声明 | string|array|null | null | 指定字段不存在时返回的备用值。 |
Request::all
返回全部输入与上传文件,支持按字段筛选;项目用于员工、桌位、取号和结账验证。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$keys | null | 要获取的字段名或字段列表;null 表示全部输入与上传文件。 |
点击展开:原始注释、声明及完整参数信息
/**
* Get all of the input and files for the request.
*
* @param mixed $keys
* @return array
*/原始声明:
public function all($keys = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$keys | 未声明 | mixed | null | 要获取的字段名或字段列表;null 表示全部输入与上传文件。 |
Request::query
读取 URL 查询字符串参数;项目中 Auth2 不传 $key,校验查询字符串是否携带 token。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$key | null | 待读取字段名;null 表示返回该输入源的全部数据。 |
$default | null | 指定字段不存在时返回的备用值。 |
点击展开:原始注释、声明及完整参数信息
/**
* Retrieve a query string item from the request.
*
* @param string|null $key
* @param string|array|null $default
* @return string|array|null
*/原始声明:
public function query($key = null, $default = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$key | 未声明 | string|null | null | 待读取字段名;null 表示返回该输入源的全部数据。 |
$default | 未声明 | string|array|null | null | 指定字段不存在时返回的备用值。 |
四、Eloquent 与数据库查询方法
Eloquent Model::query
为当前模型创建 Eloquent 查询构造器;User、Booking、Queue、Table、Mealing、Bill 都使用该继承方法。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
| 无 | 不适用 | 此函数没有声明参数。 |
点击展开:原始注释、声明及完整参数信息
/**
* Begin querying the model.
*
* @return \Illuminate\Database\Eloquent\Builder<static>
*/原始声明:
public static function query()| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
| 无 | 不适用 | 不适用 | 不适用 | 此函数没有声明参数。 |
Eloquent Model::all
查询模型表的所有记录并返回 Eloquent 集合;项目调用 Mealing::all() 获取所有用餐记录。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$columns | ['*'] | 要查询的列;默认 ["*"] 选择全部列,员工列表显式选择 id、username、type。 |
点击展开:原始注释、声明及完整参数信息
/**
* Get all of the models from the database.
*
* @param array|string $columns
* @return \Illuminate\Database\Eloquent\Collection<int, static>
*/原始声明:
public static function all($columns = ['*'])| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$columns | 未声明 | array|string | ['*'] | 要查询的列;默认 ["*"] 选择全部列,员工列表显式选择 id、username、type。 |
Eloquent Model::load
给已经取得的单个模型加载关联;项目加载 booking、table。签名只声明一个参数,但源码支持 load("table", "booking") 多个实参。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$relations | 无(必传) | 需要加载的关联名称或关联配置;项目传入 booking、table。 |
点击展开:原始注释、声明及完整参数信息
/**
* Eager load relations on the model.
*
* @param array|string $relations
* @return $this
*/原始声明:
public function load($relations)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$relations | 未声明 | array|string | 无(必传) | 需要加载的关联名称或关联配置;项目传入 booking、table。 |
Eloquent Model::update
对已取得的单个模型填充属性并保存;项目用于 token、预订状态、队列状态、桌位状态和用餐状态更新。会走模型保存和事件流程。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$attributes | [] | 需要修改的模型属性数组;例如 token 或 status,经 fill 和 save 保存。 |
$options | [] | 传递给模型 save 的保存选项;项目省略,使用空数组。 |
点击展开:原始注释、声明及完整参数信息
/**
* Update the model in the database.
*
* @param array<string, mixed> $attributes
* @param array<string, mixed> $options
* @return bool
*/原始声明:
public function update(array $attributes = [], array $options = [])| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$attributes | array | array<string, mixed> | [] | 需要修改的模型属性数组;例如 token 或 status,经 fill 和 save 保存。 |
$options | array | array<string, mixed> | [] | 传递给模型 save 的保存选项;项目省略,使用空数组。 |
Eloquent Model::delete
删除已取得的单个模型;项目用于员工和空闲桌位删除,会走模型删除事件流程。数据库外键可能继续触发级联删除。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
| 无 | 不适用 | 此函数没有声明参数。 |
点击展开:原始注释、声明及完整参数信息
/**
* Delete the model from the database.
*
* @return bool|null
*
* @throws \LogicException
*/函数体原注释:
// If the model doesn't exist, there is nothing to delete so we'll just return
// immediately and not do anything else. Otherwise, we will continue with a
// deletion process on the model, firing the proper events, and so forth.
// Here, we'll touch the owning models, verifying these timestamps get updated
// for the models. This will allow any caching to get broken on the parents
// by the timestamp. Then we will go ahead and delete the model instance.
// Once the model has been deleted, we will fire off the deleted event so that
// the developers may hook into post-delete operations. We will then return
// a boolean true as the delete is presumably successful on the database.原始声明:
public function delete()| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
| 无 | 不适用 | 不适用 | 不适用 | 此函数没有声明参数。 |
Eloquent Builder::create
按属性数组新建并保存模型,返回模型实例;项目用于用户注册和数据库填充,受 $fillable 等批量赋值规则影响。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$attributes | [] | 创建模型的属性数组;写入相应 $fillable 允许的字段。 |
点击展开:原始注释、声明及完整参数信息
/**
* Save a new model and return the instance.
*
* @param array $attributes
* @return TModel
*/原始声明:
public function create(array $attributes = [])| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$attributes | array | array | [] | 创建模型的属性数组;写入相应 $fillable 允许的字段。 |
Eloquent Builder::firstWhere
添加 where 条件并取第一条模型,没有结果返回 null;项目按 username 或 token 查询用户。二参数调用 firstWhere("token", token值) 会把第二个实参作为等值比较值。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 参与查询或排序的字段/表达式;具体由调用处传入。 |
$operator | null | 比较运算符;where/firstWhere 二参数形式时第二个实参作为值,由实现补等号。 |
$value | null | 三/四参数 where 条件的比较值;二参数形式由框架从第二个实参取值。 |
$boolean | 'and' | 条件连接方式,默认 and;本项目没有覆盖。 |
点击展开:原始注释、声明及完整参数信息
/**
* Add a basic where clause to the query, and return the first result.
*
* @param (\Closure(static): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
* @param mixed $operator
* @param mixed $value
* @param string $boolean
* @return TModel|null
*/原始声明:
public function firstWhere($column, $operator = null, $value = null, $boolean = 'and')| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | (\Closure(static): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression | 无(必传) | 参与查询或排序的字段/表达式;具体由调用处传入。 |
$operator | 未声明 | mixed | null | 比较运算符;where/firstWhere 二参数形式时第二个实参作为值,由实现补等号。 |
$value | 未声明 | mixed | null | 三/四参数 where 条件的比较值;二参数形式由框架从第二个实参取值。 |
$boolean | 未声明 | string | 'and' | 条件连接方式,默认 and;本项目没有覆盖。 |
Eloquent Builder::where
添加查询条件,返回当前查询构造器;项目筛选用户、角色、预订状态、联系人、桌型、桌位和队列状态。二参数形式 where("字段", 值) 表示等于,三参数形式可指定 !=、like 等运算符。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 参与查询或排序的字段/表达式;具体由调用处传入。 |
$operator | null | 比较运算符;where/firstWhere 二参数形式时第二个实参作为值,由实现补等号。 |
$value | null | 三/四参数 where 条件的比较值;二参数形式由框架从第二个实参取值。 |
$boolean | 'and' | 条件连接方式,默认 and;本项目没有覆盖。 |
点击展开:原始注释、声明及完整参数信息
/**
* Add a basic where clause to the query.
*
* @param (\Closure(static): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
* @param mixed $operator
* @param mixed $value
* @param string $boolean
* @return $this
*/原始声明:
public function where($column, $operator = null, $value = null, $boolean = 'and')| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | (\Closure(static): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression | 无(必传) | 参与查询或排序的字段/表达式;具体由调用处传入。 |
$operator | 未声明 | mixed | null | 比较运算符;where/firstWhere 二参数形式时第二个实参作为值,由实现补等号。 |
$value | 未声明 | mixed | null | 三/四参数 where 条件的比较值;二参数形式由框架从第二个实参取值。 |
$boolean | 未声明 | string | 'and' | 条件连接方式,默认 and;本项目没有覆盖。 |
Eloquent Builder::whereHas
只保留关联存在且符合条件的模型;quHao 对 booking 关联按 table_type 筛选。同名方法实际由 QueriesRelationships Trait 提供。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$relation | 无(必传) | 需要存在且满足条件的关联;项目为 booking。 |
$callback | null | 关联查询约束闭包;项目接收 $query 并加入 table_type 条件。 |
$operator | '>=' | 关联数量比较运算符;默认 >=,本项目省略。 |
$count | 1 | 关联数量阈值;默认 1,配合默认 >= 表示至少存在一条关联。 |
点击展开:原始注释、声明及完整参数信息
/**
* Add a relationship count / exists condition to the query with where clauses.
*
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
*
* @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
* @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|null $callback
* @param string $operator
* @param \Illuminate\Contracts\Database\Query\Expression|int $count
* @return $this
*/原始声明:
public function whereHas($relation, ?Closure $callback = null, $operator = '>=', $count = 1)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$relation | 未声明 | \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string | 无(必传) | 需要存在且满足条件的关联;项目为 booking。 |
$callback | ?Closure | (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|null | null | 关联查询约束闭包;项目接收 $query 并加入 table_type 条件。 |
$operator | 未声明 | string | '>=' | 关联数量比较运算符;默认 >=,本项目省略。 |
$count | 未声明 | \Illuminate\Contracts\Database\Query\Expression|int | 1 | 关联数量阈值;默认 1,配合默认 >= 表示至少存在一条关联。 |
Eloquent Builder::with
在查询执行前指定需要预加载的关联;quHao 使用 with("booking")。本项目随后执行 max 聚合,with 不会让聚合查询返回已加载的模型。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$relations | 无(必传) | 需要加载的关联名称或关联配置;项目传入 booking、table。 |
$callback | null | 对关联查询施加约束的回调,或源码支持的附加关系参数;项目省略。 |
点击展开:原始注释、声明及完整参数信息
/**
* Specify relationships that should be eager loaded.
*
* @param array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string>|string $relations
* @param (\Closure(\Illuminate\Database\Eloquent\Relations\Relation<*,*,*>): mixed)|string|null $callback
* @return $this
*/原始声明:
public function with($relations, $callback = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$relations | 未声明 | array<array-key, array|(\Closure(\Illuminate\Database\Eloquent\Relations\Relation<,,*>): mixed)|string>|string | 无(必传) | 需要加载的关联名称或关联配置;项目传入 booking、table。 |
$callback | 未声明 | (\Closure(\Illuminate\Database\Eloquent\Relations\Relation<,,*>): mixed)|string|null | null | 对关联查询施加约束的回调,或源码支持的附加关系参数;项目省略。 |
Eloquent Builder::find
按主键查找模型;传单个 ID 通常返回模型或 null,传 ID 数组可返回集合。项目使用单个 ID 查用户、预订、桌位、队列和用餐记录。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$id | 无(必传) | 目标模型主键或主键数组;项目传入单个用户、桌位、预订、队列或用餐 ID。 |
$columns | ['*'] | 要查询的列;默认 ["*"] 选择全部列,员工列表显式选择 id、username、type。 |
点击展开:原始注释、声明及完整参数信息
/**
* Find a model by its primary key.
*
* @param mixed $id
* @param array|string $columns
* @return ($id is (\Illuminate\Contracts\Support\Arrayable<array-key, mixed>|array<mixed>) ? \Illuminate\Database\Eloquent\Collection<int, TModel> : TModel|null)
*/原始声明:
public function find($id, $columns = ['*'])| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$id | 未声明 | mixed | 无(必传) | 目标模型主键或主键数组;项目传入单个用户、桌位、预订、队列或用餐 ID。 |
$columns | 未声明 | array|string | ['*'] | 要查询的列;默认 ["*"] 选择全部列,员工列表显式选择 id、username、type。 |
Eloquent Builder::get
执行 SELECT 并返回 Eloquent 模型集合;可指定列,员工列表使用 ["id","username","type"]。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$columns | ['*'] | 要查询的列;默认 ["*"] 选择全部列,员工列表显式选择 id、username、type。 |
点击展开:原始注释、声明及完整参数信息
/**
* Execute the query as a "select" statement.
*
* @param array|string $columns
* @return \Illuminate\Database\Eloquent\Collection<int, TModel>
*/函数体原注释:
// If we actually found models we will also eager load any relationships that
// have been specified as needing to be eager loaded, which will solve the
// n+1 query issue for the developers to avoid running a lot of queries.原始声明:
public function get($columns = ['*'])| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$columns | 未声明 | array|string | ['*'] | 要查询的列;默认 ["*"] 选择全部列,员工列表显式选择 id、username、type。 |
Eloquent Builder::latest
按指定列降序排列;getByTable 显式传入 id,再调用 first 取得该桌位主键最大的用餐记录。签名默认 null,函数内才回退到模型创建时间字段。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | null | 降序排序列;项目传入 id,省略时回退到模型创建时间字段。 |
点击展开:原始注释、声明及完整参数信息
/**
* Add an "order by" clause for a timestamp to the query.
*
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
* @return $this
*/原始声明:
public function latest($column = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string|\Illuminate\Contracts\Database\Query\Expression | null | 降序排序列;项目传入 id,省略时回退到模型创建时间字段。 |
Eloquent Builder::first
限制查询返回第一条记录,没有结果返回 null;项目用于获取桌位最新用餐记录。实际定义来自 BuildsQueries Trait。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$columns | ['*'] | 要查询的列;默认 ["*"] 选择全部列,员工列表显式选择 id、username、type。 |
点击展开:原始注释、声明及完整参数信息
/**
* Execute the query and get the first result.
*
* @param array|string $columns
* @return TValue|null
*/原始声明:
public function first($columns = ['*'])| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$columns | 未声明 | array|string | ['*'] | 要查询的列;默认 ["*"] 选择全部列,员工列表显式选择 id、username、type。 |
Query Builder::insertGetId
插入一条记录并返回生成的主键;项目通过 Eloquent 构造器转发,写入预订、队列、员工、桌位、用餐和账单。直接查询写入不会执行模型 create 的批量赋值、模型事件及自动时间戳逻辑。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$values | 无(必传) | 插入字段到值的数组;如预订数据、队列数据或账单金额。 |
$sequence | null | 需要返回的主键列/序列标识,含义取决于数据库驱动;本项目省略,使用驱动默认规则。 |
点击展开:原始注释、声明及完整参数信息
/**
* Insert a new record and get the value of the primary key.
*
* @param string|null $sequence
* @return int
*/原始声明:
public function insertGetId(array $values, $sequence = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$values | array | 未提供 @param | 无(必传) | 插入字段到值的数组;如预订数据、队列数据或账单金额。 |
$sequence | 未声明 | string|null | null | 需要返回的主键列/序列标识,含义取决于数据库驱动;本项目省略,使用驱动默认规则。 |
Query Builder::max
执行数据库 MAX 聚合,取得指定字段最大值;quHao 使用 queue_number,空结果由业务代码 ?: 0 处理。该方法由 Eloquent 构造器转发至基础查询构造器。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 要计算最大值的列;项目为 queue_number。 |
点击展开:原始注释、声明及完整参数信息
/**
* Retrieve the maximum value of a given column.
*
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
* @return mixed
*/原始声明:
public function max($column)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | \Illuminate\Contracts\Database\Query\Expression|string | 无(必传) | 要计算最大值的列;项目为 queue_number。 |
Eloquent Collection::load
给集合中所有模型批量加载关联;项目给所有用餐加载 table,给有效队列加载 booking。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$relations | 无(必传) | 需要加载的关联名称或关联配置;项目传入 booking、table。 |
点击展开:原始注释、声明及完整参数信息
/**
* Load a set of relationships onto the collection.
*
* @param array<array-key, array|(callable(\Illuminate\Database\Eloquent\Relations\Relation<*, *, *>): mixed)|string>|string $relations
* @return $this
*/原始声明:
public function load($relations)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$relations | 未声明 | array<array-key, array|(callable(\Illuminate\Database\Eloquent\Relations\Relation<*, *, *>): mixed)|string>|string | 无(必传) | 需要加载的关联名称或关联配置;项目传入 booking、table。 |
Eloquent Collection::map
对集合每个元素执行回调,传入元素和键;getAllMealing 的回调只接收元素并返回数组,因此结果转为基础 Support Collection。getMealing 的接收者是单个 Model,不能调用这个集合方法。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$callback | 无(必传) | 映射函数,框架传入 (元素, 键);项目只声明 $item,返回所需字段数组。 |
点击展开:原始注释、声明及完整参数信息
/**
* Run a map over each of the items.
*
* @template TMapValue
*
* @param callable(TModel, TKey): TMapValue $callback
* @return \Illuminate\Support\Collection<TKey, TMapValue>|static<TKey, TMapValue>
*/原始声明:
public function map(callable $callback)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$callback | callable | callable(TModel, TKey): TMapValue | 无(必传) | 映射函数,框架传入 (元素, 键);项目只声明 $item,返回所需字段数组。 |
五、门面与路由方法
Route::get → Router::get
注册 GET 路由;项目通过 Route Facade 或 RouteRegistrar 链式调用,将路径绑定到控制器方法。GET 注册同时支持 HEAD。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$uri | 无(必传) | 路由路径,可包含 {id} 等必填占位符或 {contact_mobile?} 等可选占位符。 |
$action | null | 路由处理器;项目传入 [控制器::class, "方法名"],须对应实际存在的方法。 |
点击展开:原始注释、声明及完整参数信息
/**
* Register a new GET route with the router.
*
* @param string $uri
* @param array|string|callable|null $action
* @return \Illuminate\Routing\Route
*/原始声明:
public function get($uri, $action = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$uri | 未声明 | string | 无(必传) | 路由路径,可包含 {id} 等必填占位符或 {contact_mobile?} 等可选占位符。 |
$action | 未声明 | array|string|callable|null | null | 路由处理器;项目传入 [控制器::class, "方法名"],须对应实际存在的方法。 |
Route::post → Router::post
注册 POST 路由;项目通过 Route Facade 或 RouteRegistrar 链式调用,将路径绑定到控制器方法。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$uri | 无(必传) | 路由路径,可包含 {id} 等必填占位符或 {contact_mobile?} 等可选占位符。 |
$action | null | 路由处理器;项目传入 [控制器::class, "方法名"],须对应实际存在的方法。 |
点击展开:原始注释、声明及完整参数信息
/**
* Register a new POST route with the router.
*
* @param string $uri
* @param array|string|callable|null $action
* @return \Illuminate\Routing\Route
*/原始声明:
public function post($uri, $action = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$uri | 未声明 | string | 无(必传) | 路由路径,可包含 {id} 等必填占位符或 {contact_mobile?} 等可选占位符。 |
$action | 未声明 | array|string|callable|null | null | 路由处理器;项目传入 [控制器::class, "方法名"],须对应实际存在的方法。 |
Route::delete → Router::delete
注册 DELETE 路由;项目通过 Route Facade 或 RouteRegistrar 链式调用,将路径绑定到控制器方法。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$uri | 无(必传) | 路由路径,可包含 {id} 等必填占位符或 {contact_mobile?} 等可选占位符。 |
$action | null | 路由处理器;项目传入 [控制器::class, "方法名"],须对应实际存在的方法。 |
点击展开:原始注释、声明及完整参数信息
/**
* Register a new DELETE route with the router.
*
* @param string $uri
* @param array|string|callable|null $action
* @return \Illuminate\Routing\Route
*/原始声明:
public function delete($uri, $action = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$uri | 未声明 | string | 无(必传) | 路由路径,可包含 {id} 等必填占位符或 {contact_mobile?} 等可选占位符。 |
$action | 未声明 | array|string|callable|null | null | 路由处理器;项目传入 [控制器::class, "方法名"],须对应实际存在的方法。 |
Route::redirect → Router::redirect
注册重定向路由;web.php 将 / 重定向到 register.html,默认使用 302 状态码。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$uri | 无(必传) | 重定向入口路径;项目传入 /。 |
$destination | 无(必传) | 重定向目标;项目传入 register.html。 |
$status | 302 | 重定向 HTTP 状态码;默认 302,项目省略。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a redirect from one URI to another.
*
* @param string $uri
* @param string $destination
* @param int $status
* @return \Illuminate\Routing\Route
*/原始声明:
public function redirect($uri, $destination, $status = 302)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$uri | 未声明 | string | 无(必传) | 重定向入口路径;项目传入 /。 |
$destination | 未声明 | string | 无(必传) | 重定向目标;项目传入 register.html。 |
$status | 未声明 | int | 302 | 重定向 HTTP 状态码;默认 302,项目省略。 |
Routing\RouteRegistrar::group
使用当前累积的 prefix、middleware 等属性注册一组路由;api.php 全部 group 都是链式 RouteRegistrargroup(array $attributes, $routes) 的调用形式。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$callback | 无(必传) | 注册组内路由的闭包,也支持数组或路由文件路径;本项目传入无形参闭包。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a route group with shared attributes.
*
* @param \Closure|array|string $callback
* @return $this
*/原始声明:
public function group($callback)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$callback | 未声明 | \Closure|array|string | 无(必传) | 注册组内路由的闭包,也支持数组或路由文件路径;本项目传入无形参闭包。 |
Schema::create → Schema Builder::create
创建数据库表并执行 Blueprint 回调;项目 6 个迁移分别创建 users、bookings、queues、tables、mealings、bills,由 Schema Facade 转发。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$table | 无(必传) | 数据库表名;具体表由迁移传入。 |
$callback | 无(必传) | 定义表结构的闭包,Laravel 传入 Blueprint $table;内部声明列与外键。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new table on the schema.
*
* @param string $table
* @param \Closure $callback
* @return void
*/原始声明:
public function create($table, Closure $callback)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$table | 未声明 | string | 无(必传) | 数据库表名;具体表由迁移传入。 |
$callback | Closure | \Closure | 无(必传) | 定义表结构的闭包,Laravel 传入 Blueprint $table;内部声明列与外键。 |
Schema::dropIfExists → Schema Builder::dropIfExists
数据库表存在时删除;项目在每个迁移的 down 中删除对应表,由 Schema Facade 转发。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$table | 无(必传) | 数据库表名;具体表由迁移传入。 |
点击展开:原始注释、声明及完整参数信息
/**
* Drop a table from the schema if it exists.
*
* @param string $table
* @return void
*/原始声明:
public function dropIfExists($table)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$table | 未声明 | string | 无(必传) | 数据库表名;具体表由迁移传入。 |
Route::prefix / RouteRegistrar::prefix(动态方法注解)
设置路由组 URI 前缀;项目传入 v1、user、/admin、/table、/employees、booking、/mealing。 此处只有 @method 注解,没有独立函数实体;实际实现由 Router__call 转发至 RouteRegistrar::attribute。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$prefix | 无(必传) | 路由组前缀字符串;嵌套组前缀累积形成完整 URI。 |
点击展开:原始注释、声明及完整参数信息
* @method \Illuminate\Routing\RouteRegistrar prefix(string $prefix)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$prefix | 未声明 | 未提供 @param | 无(必传) | 路由组前缀字符串;嵌套组前缀累积形成完整 URI。 |
Route::middleware / RouteRegistrar::middleware(动态方法注解)
设置路由组中间件;项目传入 auth2:ADMIN 等字符串,冒号后的角色参数交给 Auth2__call / RouteRegistrarattribute。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$middleware | 无(必传) | 中间件字符串或列表;auth2 后的 ADMIN|WORKER 等字符串限制可访问角色。 |
点击展开:原始注释、声明及完整参数信息
* @method \Illuminate\Routing\RouteRegistrar middleware(array|string|null $middleware)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$middleware | 未声明 | 未提供 @param | 无(必传) | 中间件字符串或列表;auth2 后的 ADMIN|WORKER 等字符串限制可访问角色。 |
六、数据库表结构方法
Database\Schema\Blueprint::id
添加自增无符号大整数主键列;项目所有表都使用默认 id。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 'id' | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new auto-incrementing big integer column on the table (8-byte, 0 to 18,446,744,073,709,551,615).
*
* @param string $column
* @return \Illuminate\Database\Schema\ColumnDefinition
*/原始声明:
public function id($column = 'id')| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string | 'id' | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
Database\Schema\Blueprint::string
添加可变长度字符串列;项目用于用户名、密码、token、联系人、手机号、状态等。$length 的签名默认 null,函数内部回退到 Schema Builder 的默认字符串长度,通常为 255。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$length | null | 字符串长度;签名默认 null,实际默认长度由 Schema Builder 配置决定,通常为 255。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new string column on the table.
*
* @param string $column
* @param int|null $length
* @return \Illuminate\Database\Schema\ColumnDefinition
*/原始声明:
public function string($column, $length = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$length | 未声明 | int|null | null | 字符串长度;签名默认 null,实际默认长度由 Schema Builder 配置决定,通常为 255。 |
Database\Schema\Blueprint::enum
添加枚举列;用于用户角色、桌型、队列状态、桌位状态和用餐状态。允许值由每个迁移传入的数组决定。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$allowed | 无(必传) | 数据库枚举列允许值数组;如角色、桌型或状态集合。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new enum column on the table.
*
* @param string $column
* @param array $allowed
* @return \Illuminate\Database\Schema\ColumnDefinition
*/原始声明:
public function enum($column, array $allowed)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$allowed | array | array | 无(必传) | 数据库枚举列允许值数组;如角色、桌型或状态集合。 |
Database\Schema\Blueprint::foreignId
添加无符号大整数外键字段定义;需要随后 constrained 建立外键约束,项目再用 cascadeOnDelete 配置级联删除。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new unsigned big integer column on the table (8-byte, 0 to 18,446,744,073,709,551,615).
*
* @param string $column
* @return \Illuminate\Database\Schema\ForeignIdColumnDefinition
*/原始声明:
public function foreignId($column)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
Database\Schema\Blueprint::date
添加日期列;项目用于 bookings.dining_date。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new date column on the table.
*
* @param string $column
* @return \Illuminate\Database\Schema\ColumnDefinition
*/原始声明:
public function date($column)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
Database\Schema\Blueprint::time
添加时间列;项目用于 bookings.dining_time。$precision 默认 null,实际精度在函数内部使用 defaultTimePrecision() 决定。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$precision | null | 时间字段的小数秒精度;默认 null,实际值按 Blueprint 的默认精度规则决定。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new time column on the table.
*
* @param string $column
* @param int|null $precision
* @return \Illuminate\Database\Schema\ColumnDefinition
*/原始声明:
public function time($column, $precision = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$precision | 未声明 | int|null | null | 时间字段的小数秒精度;默认 null,实际值按 Blueprint 的默认精度规则决定。 |
Database\Schema\Blueprint::integer
添加整数列;项目用于 number_guest、queue_number,未开启自增或无符号选项。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$autoIncrement | false | 是否自增;默认 false,项目没有覆盖。 |
$unsigned | false | 是否使用无符号整数;默认 false,项目没有覆盖。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new integer (4-byte) column on the table.
* Range: -2,147,483,648 to 2,147,483,647 (signed) or 0 to 4,294,967,295 (unsigned).
*
* @param string $column
* @param bool $autoIncrement
* @param bool $unsigned
* @return \Illuminate\Database\Schema\ColumnDefinition
*/原始声明:
public function integer($column, $autoIncrement = false, $unsigned = false)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$autoIncrement | 未声明 | bool | false | 是否自增;默认 false,项目没有覆盖。 |
$unsigned | 未声明 | bool | false | 是否使用无符号整数;默认 false,项目没有覆盖。 |
Database\Schema\Blueprint::char
添加固定长度字符串列;项目用于 bookings.table_type。签名默认长度 null,源码回退到默认字符串长度,不能据 A/B/C 误写为默认长度 1。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$length | null | 字符串长度;签名默认 null,实际默认长度由 Schema Builder 配置决定,通常为 255。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new char column on the table.
*
* @param string $column
* @param int|null $length
* @return \Illuminate\Database\Schema\ColumnDefinition
*/原始声明:
public function char($column, $length = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
$length | 未声明 | int|null | null | 字符串长度;签名默认 null,实际默认长度由 Schema Builder 配置决定,通常为 255。 |
Database\Schema\Blueprint::double
添加双精度浮点数列;项目用于 bills.amount。当前 Laravel 版本签名只有 $column,无精度或小数位参数。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$column | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a new double column on the table.
*
* @param string $column
* @return \Illuminate\Database\Schema\ColumnDefinition
*/原始声明:
public function double($column)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$column | 未声明 | string | 无(必传) | 新建数据库列的名称;本项目按迁移传入 id、username、number_guest、amount 等。 |
Database\Schema\Blueprint::timestamps
添加可为空的 created_at、updated_at 时间戳列;项目每张表均调用。这里只建立字段定义,insertGetId 不会因此自动填入模型时间戳。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$precision | null | 时间字段的小数秒精度;默认 null,实际值按 Blueprint 的默认精度规则决定。 |
点击展开:原始注释、声明及完整参数信息
/**
* Add nullable creation and update timestamps to the table.
*
* @param int|null $precision
* @return \Illuminate\Support\Collection<int, \Illuminate\Database\Schema\ColumnDefinition>
*/原始声明:
public function timestamps($precision = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$precision | 未声明 | int|null | null | 时间字段的小数秒精度;默认 null,实际值按 Blueprint 的默认精度规则决定。 |
Database\Schema\ForeignIdColumnDefinition::constrained
为 foreignId 建立外键约束;项目显式指定关联表,users 关联还指定 id 列。$column 签名默认 null,函数内部才回退到 id;返回 ForeignKeyDefinition 以继续配置删除策略。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
$table | null | 外键引用的目标表;项目为 users、bookings、tables、queues、mealings。null 时尝试由列名/已有配置推断。 |
$column | null | 目标表被引用的列;签名默认 null,内部一般回退到 id。users 的调用显式传入 id。 |
$indexName | null | 外键约束的自定义索引名称;省略时按数据库/框架规则生成。 |
点击展开:原始注释、声明及完整参数信息
/**
* Create a foreign key constraint on this column referencing the "id" column of the conventionally related table.
*
* @param string|null $table
* @param string|null $column
* @param string|null $indexName
* @return \Illuminate\Database\Schema\ForeignKeyDefinition
*/原始声明:
public function constrained($table = null, $column = null, $indexName = null)| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
$table | 未声明 | string|null | null | 外键引用的目标表;项目为 users、bookings、tables、queues、mealings。null 时尝试由列名/已有配置推断。 |
$column | 未声明 | string|null | null | 目标表被引用的列;签名默认 null,内部一般回退到 id。users 的调用显式传入 id。 |
$indexName | 未声明 | string|null | null | 外键约束的自定义索引名称;省略时按数据库/框架规则生成。 |
Database\Schema\ForeignKeyDefinition::cascadeOnDelete
把外键的删除策略设置为 CASCADE;删除被引用的父记录时,数据库级联删除当前表关联记录。无参数。
| 参数 | 默认值 | 含义与作用 |
|---|---|---|
| 无 | 不适用 | 此函数没有声明参数。 |
点击展开:原始注释、声明及完整参数信息
/**
* Indicate that deletes should cascade.
*
* @return $this
*/原始声明:
public function cascadeOnDelete()| 原始参数名 | 签名类型 | 原始注释类型 | 原始默认值 | 参数含义与作用 |
|---|---|---|---|---|
| 无 | 不适用 | 不适用 | 不适用 | 此函数没有声明参数。 |