/** * @param Content $content * * @return \Illuminate\View\View */ public function chooseThumbnail($content) { if (!$content->canEdit(user())) { return redirect()->route('content_comments', $content->getKey())->with('danger_msg', 'Minął czas dozwolony na edycję treści.'); } try { $thumbnails = \OEmbed::getThumbnails($content->url); } catch (\Exception $e) { $thumbnails = []; } $thumbnails[] = 'http://img.bitpixels.com/getthumbnail?code=74491&size=200&url=' . urlencode($content->url); session(compact('thumbnails')); return view('content.thumbnails', compact('content', 'thumbnails')); }
/** * @param Content $content * * @return \Illuminate\View\View */ public function chooseThumbnail($content) { if (!$content->canEdit(Auth::user())) { return Redirect::route('content_comments', $content->getKey())->with('danger_msg', 'Minął czas dozwolony na edycję treści.'); } $thumbnails = []; try { $summon = new Summon($content->getURL()); $thumbnails = $summon->fetch(); } catch (\Exception $e) { } $websiteThumbnail = 'http://img.bitpixels.com/getthumbnail?code=74491&size=100&url=' . urlencode($content->url); $thumbnails['thumbnails'][] = $websiteThumbnail; Session::put('thumbnails', $thumbnails['thumbnails']); return view('content.thumbnails', compact('content', 'thumbnails')); }
/** * @param Request $request * @param Content $content * * @return mixed */ public function edit(Request $request, $content) { if (!$content->canEdit(user())) { return response()->json(['status' => 'error', 'error' => 'Minął czas dozwolony na edycję treści.'], 400); } $rules = ['title' => 'min:1|max:128|not_in:edit,thumbnail', 'description' => 'max:255']; if ($content->text) { $rules['text'] = 'min:1|max:50000'; } else { $rules['url'] = 'url_custom|max:2048'; } $this->validate($request, $rules); $fields = ['title', 'description', 'nsfw', 'eng']; $fields[] = $content->text ? 'text' : 'url'; $content->update(Input::only($fields)); }
/** * @param Content $content * * @return $this|\Illuminate\Http\RedirectResponse */ public function editContent($content) { if (!$content->canEdit(user())) { return Redirect::route('content_comments', $content->getKey())->with('danger_msg', 'Minął czas dozwolony na edycję treści.'); } $rules = ['title' => 'required|min:1|max:128|not_in:edit,thumbnail', 'description' => 'max:255']; if ($content->text) { $rules['text'] = 'required|min:1|max:50000'; } else { $rules['url'] = 'required|url_custom|max:2048'; } $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::action('ContentController@showEditForm', $content->getKey())->withInput()->withErrors($validator); } $data = request()->only(['title', 'description', 'nsfw', 'eng']); $content->fill($data); if ($content->text) { $content->text = request('text'); } else { $content->url = request('url'); } $content->save(); return Redirect::route('content_comments', $content); }