本文整理匯總了PHP中App\Http\Requests\Request::segment方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::segment方法的具體用法?PHP Request::segment怎麽用?PHP Request::segment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類App\Http\Requests\Request
的用法示例。
在下文中一共展示了Request::segment方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if (Request::segment(3) == 'create') {
$this->rules['file_name'] .= '|required';
}
return $this->rules;
}
示例2: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
switch ($this->method()) {
case 'POST':
return ['email' => 'required|email|unique:users,email', 'first_name' => 'required', 'last_name' => 'required', 'password' => 'required'];
case 'PUT':
case 'PATCH':
return ['email' => 'required|email|unique:users,email,' . Request::segment(2) . ',id', 'first_name' => 'required', 'last_name' => 'required'];
break;
default:
break;
}
}
示例3: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
switch ($this->method()) {
case 'POST':
return ['name' => 'required|unique:groups,name|max:50'];
case 'PUT':
case 'PATCH':
return ['name' => 'required|unique:groups,name,' . Request::segment(2) . ',id'];
break;
default:
break;
}
}