public function store(Request $request, $content)
 {
     $this->validate($request, ContentRelated::rules());
     if (Auth::user()->isBanned($content->group)) {
         return Response::json(['status' => 'error', 'error' => 'Użytkownik został zbanowany w wybranej grupie.']);
     }
     $related = new ContentRelated(Input::only(['title', 'url', 'nsfw', 'eng']));
     if (Input::get('thumbnail') != 'false' && Input::get('thumbnail') != 'off') {
         $url = OEmbed::getThumbnail($this->url);
         if ($url) {
             $related->setThumbnail($url);
         }
     }
     $related->user()->associate(Auth::user());
     $related->content()->associate($content);
     $related->save();
     return Response::json(['status' => 'ok', '_id' => $related->hashId(), 'related' => $related]);
 }
示例#2
0
 /**
  * @param  string  $id
  * @param  string  $type
  * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model
  */
 private function getObject($id, $type)
 {
     $id = \Hashids::decode($id);
     $id = current($id);
     switch ($type) {
         case 'content':
             return Content::findOrFail($id);
         case 'related':
             return ContentRelated::findOrFail($id);
         case 'entry':
             return Entry::findOrFail($id);
         case 'entry_reply':
             return EntryReply::findOrFail($id);
         case 'comment':
             return Comment::findOrFail($id);
         case 'comment_reply':
             return CommentReply::findOrFail($id);
     }
 }