Created
September 13, 2016 14:37
-
-
Save carlosocarvalho/4321a01325e5099cec0468cb2f6b1741 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 | |
/** | |
* 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