Forked from jonathanmarvens/app.controllers.BaseController.php
Created
August 13, 2013 18:36
-
-
Save sulco/6224212 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
class BaseController extends Controller { | |
private $application_name = 'The Cool Kid'; | |
protected $layout = 'base'; | |
// The cool kids' way of handling page titles. | |
protected $title = array( | |
'parent' => '', | |
'seperator' => '::', | |
'child' => '', | |
); | |
public function __construct() { | |
$instance = $this; | |
View::composer($this->layout, function ($view) use ($instance) { | |
$view->with('title', (implode(' ', $instance->title) . ' - ' . $instance->application_name)); | |
}); | |
} | |
protected function setupLayout() { | |
if (! is_null($this->layout)) { | |
$this->layout = View::make($this->layout); | |
} | |
} | |
} |
This file contains hidden or 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 | |
class UserController extends \BaseController { | |
public function __construct() { | |
parent::__construct(); | |
$this->title['parent'] = 'User'; | |
} | |
public function getLogin() { | |
$this->title['child'] = 'Login'; | |
if (Auth::check()) { | |
return 'Useless return...'; | |
} else { | |
$this->layout->content = View::make('user.login'); | |
} | |
} | |
} |
This file contains hidden or 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 | |
Route::controller( | |
'user', | |
'UserController', | |
array( | |
'getLogin' => 'user_login', | |
) | |
); | |
Route::any('/', array( | |
'as' => 'base', | |
function () { | |
return Redirect::route('user_login'); | |
}, | |
)); |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>{{ $title }}</title> | |
</head> | |
<body> | |
@yield('content') | |
</body> | |
</html> |
This file contains hidden or 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
@extends('base') | |
@section('content') | |
<p>This is my body content.</p> | |
@stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment