Exemple #1
0
 public function writePost()
 {
     $postValue = \Input::get('Post');
     $post = new Post();
     $post->fill($postValue);
     $post->setAttribute('user_id', \Auth::user()->id);
     $post->save();
     return redirect(route('home'));
 }
 /**
  * @inheritdoc
  */
 public function getRelationships($comment, array $includeRelationships = [])
 {
     /** @var Comment $comment */
     // that's an example how $includeRelationships could be used for reducing requests to database
     if (isset($includeRelationships['post']) === true) {
         // as post will be included as full resource we have to give full resource
         $post = $comment->post;
     } else {
         // as post will be included as just id and type so it's not necessary to load it from database
         $post = new Post();
         $post->setAttribute($post->getKeyName(), $comment->post_id);
     }
     return ['post' => [self::DATA => $post]];
 }