本文整理汇总了PHP中Illuminate\Http\Request::offsetSet方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::offsetSet方法的具体用法?PHP Request::offsetSet怎么用?PHP Request::offsetSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::offsetSet方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTransformInputDataNested
public function testTransformInputDataNested()
{
// Create a request object to test
$request = new Request();
$request->offsetSet('firstName', 'foo');
$request->offsetSet('lastname', 'bar');
$request->offsetSet('nestedArray', ['fooBar' => 'bar', 'foo' => 'bar', 'oneMore' => ['andThis' => true]]);
$result = $this->executeRequestWithMiddleware($request)->all();
$this->assertArrayEquals(['first_name', 'lastname', 'nested_array'], array_keys($result));
$this->assertEquals('bar', array_get($result, 'nested_array.foo_bar'));
$this->assertTrue(array_get($result, 'nested_array.one_more.and_this'));
}
示例2: updatePersonal
public function updatePersonal(Request $request)
{
//dd($request->all());
$request->offsetSet('date_of_birth', (new Carbon($request->date_of_birth))->toDateTimeString());
$request->user->update($request->all());
flash('Your information has been updated.');
return redirect('/profile/' . $request->user->id . '/update/personal');
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
foreach ($request->all() as $key => $value) {
// Handle snakecase conversion in sub arrays
if (is_array($value)) {
$value = $this->renameKeys($value);
$request->offsetSet($key, $value);
}
// Find any potential camelCase keys in the 'root' array, and convert
// them to snake_case
if (!ctype_lower($key)) {
// Only convert if the key will change
if ($key != snake_case($key)) {
$request->offsetSet(snake_case($key), $value);
$request->offsetUnset($key);
}
}
}
return $next($request);
}
示例4: handle
/**
* Handles the HTTP request.
*
* @param Illuminate\Http\Request $request The request
* @param Closure $next Mechanism for passing the result down the pipeline to the next piece of middleware
*
* @return Illuminate\Http\Response A Response object that is passed to the next piece of middleware
*/
public function handle($request, Closure $next)
{
if ($request->path() === config('auto-deploy.route')) {
if (!config('auto-deploy.require-ssl') || $request->secure()) {
$origin = $this->determineOrigin();
if (null !== $origin) {
if ($origin->isAuthentic()) {
// set the origin type in the controller
$request->offsetSet('origin', $origin);
return $next($request);
} else {
abort(403, 'Forbidden. Could not verify the origin of the request.');
}
} else {
abort(403, 'Forbidden. Could not determine the origin of the request.');
}
} else {
abort(403, 'Forbidden. Webhook requests must be sent using SSL.');
}
}
// Passthrough if it's not our specific route
return $next($request);
}
示例5: offsetSet
/**
* Set the value at the given offset.
*
* @param string $offset
* @param mixed $value
* @return void
* @static
*/
public static function offsetSet($offset, $value)
{
\Illuminate\Http\Request::offsetSet($offset, $value);
}
示例6: postReset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postReset(Request $request)
{
$token = Input::get('token');
if (is_null($token)) {
throw new NotFoundHttpException();
}
$row = PasswordReset::where("token", '=', $token)->first();
if (!$row) {
return redirect("password/email")->withError("This password reset token is invalid.");
}
$request->offsetSet("email", $row->email);
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect($this->redirectPath())->withMessage("Your Password has been Successfully Changed");
default:
return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
}
}
示例7: getUpdate
public function getUpdate(Request $request, $id = null)
{
$post = Posts::findOrFail($id);
$tags = $post->tags;
if (Gate::denies('update-post', $post)) {
return redirect(route('home'));
}
$html_content = $post->content;
$markdown_content = $post->markdown_content;
if (empty($markdown_content) && $html_content) {
$markdown_content = $this->htmlMarkdownConvertor->convertHtmlToMarkdown($html_content);
}
$page_title = 'Edit Post';
$request->offsetSet('id', $post->id);
$request->offsetSet('title', $post->title);
$request->offsetSet('content', $markdown_content);
$request->offsetSet('active', $post->active);
$request->offsetSet('category_id', $post->category_id);
if (count($tags) > 0) {
$taglist = "";
foreach ($tags as $tag) {
$taglist .= $tag->name . ',';
}
$request->offsetSet('tags', $taglist);
} else {
$request->offsetSet('tags', '');
}
$categories = Categories::all();
$tags = Tags::all();
$data = compact('page_title', 'categories', 'tags');
return view('posts.edit', $data);
}