Last active
November 29, 2015 21:37
-
-
Save valdiney/ad2b3e867cf581e99e5c to your computer and use it in GitHub Desktop.
Ofir, exemplo of the controller
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 Home extends Controller | |
{ | |
protected $view; | |
protected $model; | |
public function __construct() | |
{ | |
$this->view = new View(); | |
$this->model = $this->load_model('user.User'); | |
} | |
public function index() | |
{ | |
$data['page_title'] = 'Ofir-Framework'; | |
$this->view->set('data', $data); | |
$this->view->make('home.home'); | |
} | |
public function cadastrar() | |
{ | |
$data['login'] = Input::in_post('login'); | |
if ($this->model->save($data)) { | |
echo 'Login cadastrado.'; | |
} else { | |
echo 'Erro ao cadastrar.'; | |
} | |
} | |
public function editar() | |
{ | |
$id = Input::in_get('id'); | |
$data['login'] = Input::in_post('login'); | |
if ($this->model->update($data, $id)) { | |
echo 'Login Editado'; | |
} else { | |
echo 'Erro ao Editar'; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment