This file contains 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 | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Welcome extends CI_Controller { | |
public function index() | |
{ | |
// Define as chaves de acesso à API | |
$dados['siteKey'] = 'SUA_SITE_KEY'; | |
$dados['secretKey'] = 'SUA_SECRET_KEY'; |
This file contains 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 | |
use CodeIgniter\HTTP\Response; | |
$response = new Response(); | |
$response->setStatusCode(Response::HTTP_OK); | |
$response->setBody($output); | |
$response->setHeader('Content-type', 'text/html'); | |
$response->noCache(); |
This file contains 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 | |
use \CodeIgniter\Database\ConnectionInterface; | |
class UserModel extends \CodeIgniter\Model | |
{ | |
protected $table = 'users'; | |
protected $primaryKey = 'id'; | |
protected $returnType = 'array'; |
This file contains 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 | |
use \CodeIgniter\Database\ConnectionInterface; | |
class UserModel | |
{ | |
protected $db; | |
public function __construct(ConnectionInterface &$db) | |
{ |
This file contains 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 | |
//Configuração inicial | |
$routes->setDefaultNamespace('App\Controllers'); | |
$routes->setDefaultController('Home'); | |
$routes->setDefaultMethod('index'); | |
$routes->setTranslateURIDashes(false); | |
$routes->set404Override(); | |
$routes->setAutoRoute(false); |
This file contains 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 | |
/* | |
* Essa função vai responder pela rota /api/usuarios sob o método POST | |
*/ | |
public function index_post() | |
{ | |
// recupera os dados informado no formulário | |
$usuario = $this->post(); | |
// verifica se a foto foi selecionada e faz o processamento |
This file contains 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 | |
/** | |
* Executa o upload da imagem | |
* @param string $input_name nome do campo "file" no formulário | |
* @return array | |
*/ | |
private function UploadImage($input_name) | |
{ | |
// Carrega a biblioteca de upload | |
$this->load->library('upload'); |
This file contains 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
$(document).ready(function() { | |
/* Configurações para o datatables */ | |
var el_datatable = $('#DataTableUsuarios').DataTable({ | |
"language":{ | |
"url": "//cdn.datatables.net/plug-ins/1.10.12/i18n/Portuguese-Brasil.json" | |
}, | |
"processing": true, | |
"serverSide": false, | |
"ajax": { |
This file contains 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
<div class="modal fade" id="formUsuarioModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |
<div class="modal-dialog" role="document"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |
<h4 class="modal-title" id="myModalLabel">Novo Usuário</h4> | |
</div> | |
<div class="modal-body"> | |
<form class="form-horizontal" method="POST" action="<?=base_url('api/usuarios')?>" id="formUsuario" enctype="multipart/form-data"> | |
<div class="form-group"> |
This file contains 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 | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
$hook['pre_system'] = array( | |
'class' => 'WhoopsErrorHandler', | |
'function' => 'WhoopsConfig', | |
'filename' => 'WhoopsErrorHandler.php', | |
'filepath' => 'hooks', | |
'params' => array() | |
); |