/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { //$chapter = Chapter::find($id); $chapter = Chapter::where('id', '=', $id)->orWhere('slug', '=', $id)->first(); $book = Book::where('id', '=', $chapter->book_id)->first(); if ($chapter) { if (!$book && $chapter->public_state == true) { $markdownParser = new MarkdownParser(); $markdownText = $markdownParser->transformMarkdown($chapter->text); return View::make('chapter.single', array('chapter' => $chapter, 'chapter_text' => $markdownText, 'pageTitle' => 'Chapter: ' . $chapter->title)); } elseif ($chapter->public_state == true && $book && $book->public_state == true) { $markdownParser = new MarkdownParser(); $markdownText = $markdownParser->transformMarkdown($chapter->text); return View::make('chapter.single', array('chapter' => $chapter, 'chapter_text' => $markdownText, 'pageTitle' => 'Chapter: ' . $chapter->title)); } elseif (Sentry::Check() && $chapter->author_id == Sentry::getUser()->id) { $markdownParser = new MarkdownParser(); $markdownText = $markdownParser->transformMarkdown($chapter->text); return View::make('chapter.single', array('chapter' => $chapter, 'chapter_text' => $markdownText, 'pageTitle' => 'Chapter: ' . $chapter->title)); } else { return Redirect::to('/')->with('global_error', 'You can\'t access private resources without a secret link, which can be received from creation\'s author.'); } } return Redirect::to('/')->with('global_error', 'Sorry, chapter you are trying to reach doesn\'t exist.'); }
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::get('/', function () { if (!Sentry::Check()) { return View::make("login.index"); } else { return Redirect::route("front_report_livestock_index_get"); } }); /* ---*/ Route::get('login', array("as" => "login_get", function () { if (!Sentry::check()) { return View::make('login.index'); } else { return Redirect::route('front_report_livestock_index_get'); } })); /*Route xu ly duogn dan kg tim thay */ Route::get("error.html", array("as" => "error_page", function () { return View::make('errors.somethingwentwrong'); }));
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $book = Book::where('id', '=', $id)->orWhere('slug', '=', $id)->first(); $chapters = Chapter::where('book_id', '=', $book->id)->where('public_state', '=', true)->paginate(15); if ($book) { if ($book->public_state == true) { return View::make('book.single', array('book' => $book, 'chapters' => $chapters, 'pageTitle' => 'Book: ' . $book->title)); } elseif (Sentry::Check() && $book->author_id == Sentry::getUser()->id) { return View::make('book.single', array('book' => $book, 'chapters' => $chapters, 'pageTitle' => 'Book: ' . $book->title)); } else { return Redirect::to('/')->with('global_error', 'You can\'t access private resources without a secret link, which can be received from creation\'s author.'); } } return Redirect::to('/')->with('global_error', 'Sorry, book you are trying to reach doesn\'t exist.'); }