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
/** | |
* Add or change flashdata, only available | |
* until the next request | |
* | |
* @access public | |
* @param mixed | |
* @param string | |
* @return void | |
*/ | |
function set_flashdata($newdata = array(), $newval = '') |
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
public function login() | |
{ | |
// Caso o usuário já esteja logado, redireciona ele. | |
if($this->_needlogin(FALSE)) | |
{ | |
redirect('account'); | |
} | |
// Exibe se existe mensagem pendente (notificação) | |
if($message = $this->session->flashdata('logout')) |
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 | |
$now = DateTime::createFromFormat('d/m/Y', '21/06/2014'); | |
$tomorrow = DateTime::createFromFormat('d/m/Y', '22/06/2014'); | |
var_dump($now == $tomorrow); | |
var_dump($now < $tomorrow); | |
var_dump($now > $tomorrow); |
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 | |
//INICIALIZA A SESSÃO | |
session_start(); | |
$_SESSION["disciplinas"] = array(1 => 'curso 1', 2 => 'curso 2'); | |
$_POST["disciplinas"] = array(3 => 'curso'); | |
// Verifica se há chamadas de POST | |
if(!empty($_POST)) | |
{ |
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 | |
$arrayIdiomas = array('portugues' => 'idioma.portugues.php', 'english' => 'idioma.ingles.php', 'espanol' => 'idioma.espanhol.php', 'alemao' => 'idioma.alemao.php'); // definindo todos os idiomas disponiveis | |
// Definindo o idioma padrão | |
if(!isset($_SESSION['idIdioma'])){ | |
$_SESSION['idIdioma'] = 'portugues'; | |
} | |
if(isset($_REQUEST['idioma'])){ |
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 | |
class Template { | |
private $words; | |
public function SetKeywords($Setkeyword, $Setvalue){ | |
if(gettype($this->words) != 'array'){ | |
$this->words = array(); | |
} | |
$array = array($Setkeyword => $Setvalue); | |
$this->words = array_merge($array,$this->words); |
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 | |
namespace App\Modules\News\Models; | |
use Carbon\Carbon, Model\Category, Model\Tags, Model\Categorys, Debugbar; | |
class News extends \Eloquent { | |
public $with = [ 'tags', 'category' ]; // related relationship |
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 | |
$client = new SoapClient('http://www.url.com.br/ws.asmx?WSDL'); // URL de chamada. | |
$function = 'cep'; // qual função você quer trabalhar? No manual do webservice escolhido será disponibilizado a lista de todas. | |
// Aqui você define os argumentos que deseja enviar para a chamada. Por exemplo caso eu estivesse utilizando um WS do correiros, e desejasse retornar CEP. | |
$arguments= array('cep' => array( | |
'uf' => 'sp', | |
'cidade' => 'borba' | |
)); |
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
public function postAtendimentos() | |
{ | |
// Regras de validação do formulário | |
$validator = \Validator::make(\Input::all(), | |
array( | |
'assunto' => 'required|min:5', | |
'cliente' => 'required|min:1', | |
'categoria' => 'required|min:1', | |
'descricao' => 'required|min:20', | |
'status' => 'required|min:5' |
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 | |
$current_date = new DateTime( '2014-10-24 21:37:00' ); // 2011-12-04 20:13:35 | |
$current_date->add( new DateInterval( 'PT22H' ) ); | |
echo $current_date->format( 'Y-m-d H:i:s' ); // 2011-12-07 20:13:35 |