public function getDocument($slug)
 {
     $doc = Doc::findDocBySlug($slug);
     $introtext = $doc->introtext()->first()['meta_value'];
     $doc->introtext = $introtext;
     $doc->enableCounts();
     return Response::json($doc);
 }
Exemple #2
0
 public function getEmbedded($slug = null)
 {
     $doc = Doc::findDocBySlug($slug);
     if (is_null($doc)) {
         App::abort('404');
     }
     $view = View::make('doc.reader.embed', compact('doc'));
     return $view;
 }
Exemple #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->doc) {
         $doc = Doc::find($request->doc);
     } else {
         $doc = Doc::findDocBySlug($request->slug);
     }
     $user = Auth::user();
     if (!$doc->canUserView($user)) {
         if ($request->ajax()) {
             return response('Unauthorized.', 403);
         } else {
             return redirect()->guest('auth/login');
         }
     }
     return $next($request);
 }
 public function getSocialDoc($slug)
 {
     $doc = Doc::findDocBySlug($slug);
     if ($doc) {
         $content = array('title' => $doc->title, 'description' => $doc->introtext()->first()['meta_value'], 'image' => $doc->thumbnail);
         return view('layouts.social', $content);
     }
 }