Created
May 21, 2015 13:22
-
-
Save sleeping-owl/a724d3ca3c6cdfeeac9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Database\Eloquent\ModelNotFoundException; | |
class MonumentsController extends Controller | |
{ | |
public function getIndex() | |
{ | |
$article = Article::whereUrl('system/monuments')->first(); | |
if (!$article) | |
{ | |
$article = new Article; | |
$article->title = 'Памятники'; | |
} | |
return View::make('monuments.index', compact('article')); | |
} | |
public function getCategory($categoryUrl) | |
{ | |
$category = MonumentCategory::whereUrl($categoryUrl)->first(); | |
if (!$category) App::abort(404); | |
$monuments = $category->monuments()->with('district')->get(); | |
return View::make('monuments.category', compact('category', 'monuments')); | |
} | |
public function getDistrict($districtUrl) | |
{ | |
$district = District::whereUrl($districtUrl)->first(); | |
if (!$district) App::abort(404); | |
$monuments = $district->monuments()->with('district')->get(); | |
return View::make('monuments.category', compact('monuments'))->withCategory($district); | |
} | |
public function getFull($monumentId) | |
{ | |
try | |
{ | |
$monument = Monument::findOrFail($monumentId); | |
} catch (ModelNotFoundException $e) | |
{ | |
App::abort(404); | |
} | |
return View::make('monuments.full', compact('monument')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment