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


PHP Article::restore方法代码示例

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


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

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Article $article, Request $request)
 {
     $validator = Validator::make($request->all(), ['published' => 'sometimes|date', 'title' => 'sometimes|min:3|max:255', 'group' => 'sometimes|integer', 'comments' => 'sometimes|boolean', 'content' => 'sometimes|min:10', 'help' => 'sometimes|boolean', 'approve' => 'sometimes|boolean|required_with:content', 'revision' => 'sometimes|integer', 'reason' => 'required_with:title|max:255', 'deleted' => 'sometimes|date']);
     if ($validator->passes()) {
         // TBD check user has write access to group
         if ($article->deleted_at !== null && $request->has('deleted') && $request->deleted === null) {
             $article->restore();
             return $this->respondWithItem($article, new ArticleTransformer());
         } else {
             $article->allow_comments = $request->exists('comments') ? (bool) $request->comments : $article->allow_comments;
             $article->group_id = $request->exists('group') ? (bool) $request->group : $article->group_id;
             if ($request->title && $request->content) {
                 $content = $this->createArticleContent($article, $request, $request->reason);
                 if ($content) {
                     return $this->respondWithItem($content, new ArticleContentTransformer());
                 }
             } else {
                 if ($request->has('revision')) {
                     // check is admin
                     $article->content_id = $request->exists('revision') ? $request->revision : $article->content_id;
                     $this->approveContent($article, $request->revision);
                 }
             }
             if ($article->save()) {
                 return $this->respondWithItem($article, new ArticleTransformer());
             } else {
                 return $this->errorInternal('Unable to update article');
             }
         }
     } else {
         return $this->errorValidation($validator->messages());
     }
 }
开发者ID:jasonb8293,项目名称:fox-api,代码行数:39,代码来源:ArticleController.php


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