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


PHP Topic::toArray方法代码示例

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


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

示例1: create

 public function create()
 {
     foreach ($this->required as $required => $strlen) {
         if (!Input::has($required) || strlen(Input::get($required)) < $strlen) {
             return Response::make(['error' => 'You must introduce a ' . $required . ' with ' . $strlen . ' of length...'], 404);
         }
     }
     $new = new Topic();
     $new->fill(Input::only(['title', 'author', 'message']));
     $new->place = $this->place;
     $new->save();
     return Response::make(['success' => 'You just created a new topic!', 'topic' => $new->toArray()], 404);
 }
开发者ID:roffjump,项目名称:forum,代码行数:13,代码来源:TopicRestApiController.php

示例2: transformData

 /**
  * Transform the \Topic entity.
  *
  * @param Topic $model
  *
  * @return array
  */
 public function transformData($model)
 {
     $data = $model->toArray();
     $data['links'] = ['details_web_view' => route('topic.web_view', $model->id), 'replies_web_view' => route('replies.web_view', $model->id), 'web_url' => trim(config('app.url'), '/') . '/topics/' . $model->id];
     return $data;
 }
开发者ID:adminrt,项目名称:phphub-server,代码行数:13,代码来源:TopicTransformer.php

示例3: transformData

 /**
  * Transform the \Topic entity.
  *
  * @param Topic $model
  *
  * @return array
  */
 public function transformData($model)
 {
     return $model->toArray();
     return ['id' => (int) $model->id, 'title' => $model->title, 'body' => $model->body, 'user_id' => (int) $model->user_id, 'node_id' => (int) $model->node_id, 'is_excellent' => (bool) $model->is_excellent, 'is_wiki' => (bool) $model->is_wiki, 'view_count' => (int) $model->view_count, 'reply_count' => (int) $model->reply_count, 'favorite_count' => (int) $model->favorite_count, 'vote_count' => (int) $model->vote_count, 'created_at' => $model->created_at, 'updated_at' => $model->updated_at];
 }
开发者ID:royalwang,项目名称:phphub-server,代码行数:12,代码来源:TopicTransformer.php

示例4: newTopic

 /**
  * Crée un nouveau topic dans le forum désiré
  *
  * @param $slug Slug du forum dans lequel sera le topic
  * @param $id Id du forum dans lequel sera le topic
  */
 public function newTopic($slug, $id)
 {
     $user = Auth::user();
     $forum = Forum::find($id);
     $category = $forum->getCategory();
     $parsedContent = null;
     // L'utilisateur possède le droit de crée un topic ici
     if ($category->getPermission()->start_topic != true) {
         return Redirect::route('forum_index')->with('message', 'You can\'t start a new topic here');
     }
     // Prévisualisation du post
     if (Request::getMethod() == 'POST' && Input::get('preview') == true) {
         $code = new Decoda\Decoda(Input::get('content'));
         $code->defaults();
         $parsedContent = $code->parse();
     }
     if (Request::getMethod() == 'POST' && Input::get('post') == true) {
         // Crée le topic
         $topic = new Topic();
         $topic->name = Input::get('title');
         $topic->slug = Str::slug(Input::get('title'));
         $topic->state = 'open';
         $topic->first_post_user_id = $topic->last_post_user_id = $user->id;
         $topic->first_post_user_username = $topic->last_post_user_username = $user->username;
         $topic->views = 0;
         $topic->pinned = false;
         $topic->forum_id = $forum->id;
         $v = Validator::make($topic->toArray(), $topic->rules);
         if ($v->passes()) {
             $topic->save();
             $post = new Post();
             $post->content = Input::get('content');
             $post->user_id = $user->id;
             $post->topic_id = $topic->id;
             $v = Validator::make($post->toArray(), $post->rules);
             if ($v->passes()) {
                 $post->save();
                 $topic->num_post = 1;
                 $topic->save();
                 $forum->num_topic = $forum->getTopicCount($forum->id);
                 $forum->num_post = $forum->getPostCount($forum->id);
                 $forum->last_topic_id = $topic->id;
                 $forum->last_topic_name = $topic->name;
                 $forum->last_topic_slug = $topic->slug;
                 $forum->last_post_user_id = $user->id;
                 $forum->last_post_user_username = $user->username;
                 $forum->save();
                 return Redirect::route('forum_topic', array('slug' => $topic->slug, 'id' => $topic->id));
             } else {
                 // Impoossible de save le premier post donc delete le topic
                 $topic->delete();
             }
         } else {
             Session::put('message', 'An error has occurred with this topic. Try again.');
         }
     }
     return View::make('forum.new_topic', array('forum' => $forum, 'category' => $category, 'parsedContent' => $parsedContent, 'title' => Input::get('title'), 'content' => Input::get('content')));
 }
开发者ID:raphaeljorge,项目名称:tor,代码行数:64,代码来源:ForumController.php


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