Skip to content

Instantly share code, notes, and snippets.

View juniorb2ss's full-sized avatar
🎯
Focusing

Carlos E. Oliveira juniorb2ss

🎯
Focusing
View GitHub Profile
/**
* Add or change flashdata, only available
* until the next request
*
* @access public
* @param mixed
* @param string
* @return void
*/
function set_flashdata($newdata = array(), $newval = '')
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'))
<?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);
<?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))
{
<?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'])){
<?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);
<?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
<?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'
));
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'
<?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