当前位置: 首页>>代码示例>>PHP>>正文


PHP PostRequest::only方法代码示例

本文整理汇总了PHP中App\Http\Requests\PostRequest::only方法的典型用法代码示例。如果您正苦于以下问题:PHP PostRequest::only方法的具体用法?PHP PostRequest::only怎么用?PHP PostRequest::only使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Http\Requests\PostRequest的用法示例。


在下文中一共展示了PostRequest::only方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: putThread

 /**
  * Handles the creation of a new thread or reply.
  *
  * @param  \App\Http\Requests\PostRequest  $request
  * @param  Board  $board
  * @param  Post|null  $thread
  * @return Response (redirects to the thread view)
  */
 public function putThread(PostRequest $request, Board $board, Post $thread = null)
 {
     // Create the post.
     $post = new Post($request->all());
     $post->submitTo($board, $thread);
     // Log staff posts.
     if ($post->capcode_id) {
         $this->log('log.post.capcode', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "capcode" => $post->capcode->getCapcodeName(), "role" => $post->capcode->role]);
     }
     $input = $request->only('updatesOnly', 'updateHtml', 'updatedSince');
     if ($request->wantsJson()) {
         $updatedSince = Carbon::createFromTimestamp($request->input('updatedSince', Carbon::now()->subMinutes(4)->timestamp));
         $includeHTML = isset($input['updateHtml']);
         $posts = Post::getUpdates($updatedSince, $board, $thread, $includeHTML);
         $post->setAppendHTML($includeHTML);
         $posts->push($post);
         $posts->sortBy('board_id');
         return $posts;
     }
     // Redirect to the new post or thread.
     if ($post->reply_to_board_id) {
         return redirect("{$board->board_uri}/thread/{$post->reply_to_board_id}#{$post->board_id}");
     } else {
         return redirect("{$board->board_uri}/thread/{$post->board_id}#{$post->board_id}");
     }
 }
开发者ID:JEWSbreaking8chan,项目名称:infinity-next,代码行数:34,代码来源:BoardController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\PostRequest $request, $id)
 {
     $post = Posts::where('id', $id)->firstOrFail();
     if (!empty($request->file('image')) && $request->file('image')->isValid()) {
         $destinationPath = public_path() . "/images/";
         // upload path
         $extension = $request->file('image')->getClientOriginalExtension();
         // getting image extension
         $fileName = $post->url . '.' . $extension;
         // renameing image
         $request->file('image')->move($destinationPath, $fileName);
         // uploading file to given path
         $post->image = $fileName;
     }
     $post->fill($request->only(['title', 'post']));
     $post->save();
     Posts::findOrFail($id)->tags()->detach();
     $tags = [];
     foreach ($this->getTags($request->input('tags')) as $tag) {
         if (!empty($tag)) {
             $isFind = Tags::where('name', $tag)->get()->count();
             if ($isFind == 0) {
                 $tags[] = new Tags(['name' => $tag]);
             } else {
                 $tags[] = Tags::where('name', $tag)->first();
             }
         }
     }
     $post->tags()->saveMany($tags);
     return back();
 }
开发者ID:draaslan,项目名称:codeman,代码行数:38,代码来源:PostController.php


注:本文中的App\Http\Requests\PostRequest::only方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。