Skip to content

Instantly share code, notes, and snippets.

@carlosocarvalho
Created September 13, 2016 14:37
Show Gist options
  • Save carlosocarvalho/4321a01325e5099cec0468cb2f6b1741 to your computer and use it in GitHub Desktop.
Save carlosocarvalho/4321a01325e5099cec0468cb2f6b1741 to your computer and use it in GitHub Desktop.
<?php
/**
* Controller Demo for user Register events.
*
*/
class Register extends CI_Controller{
public function __construct(){
parent::__construct();
/**
* Vamos registrar o nossos eventos aqui no construct
* Como já adcionamos nossa lib no autoload.php
**/
//registrado nossa primeira classe no evento
Events::register('create:user', \Leilao\Events\RegisterUserMailerEvent::class);
//registrado nossa segunda classe no evento
Events::register('create:user', \Leilao\Events\RegisterUserSMSEvent::class);
}
/**
*
* @return html response
*/
public function index(){
$this->load->view('user/register');
}
/**
*
*
*/
public function store(){
$data = $this->input->post();
$this->load->model('User/RegisterModel');
if( $this->RegisterModel->insert('users', $data) )
Events::trigger('create:user');
}
public function update(){
$data = $this->input->post();
$this->load->model('User/RegisterModel');
if( $this->RegisterModel->update('users', ['id'=>1], $data) )
Events::trigger('update:user');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment