Skip to content

Instantly share code, notes, and snippets.

@valdiney
Last active November 29, 2015 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valdiney/ad2b3e867cf581e99e5c to your computer and use it in GitHub Desktop.
Save valdiney/ad2b3e867cf581e99e5c to your computer and use it in GitHub Desktop.
Ofir, exemplo of the controller
<?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