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 | |
namespace app\Models; | |
use Illuminate\Database\Eloquent\Model; | |
/** | |
* Class Segment. | |
*/ | |
class Segment extends Model |
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
function removeAcentos($Msg) { | |
$a = array ( | |
"/[ÂÀÁÄÃ]/" => "A", | |
"/[âãàáä]/" => "a", | |
"/[ÊÈÉË]/" => "E", | |
"/[êèéë]/" => "e", | |
"/[ÎÍÌÏ]/" => "I", | |
"/[îíìï]/" => "i", | |
"/[ÔÕÒÓÖ]/" => "O", | |
"/[ôõòóö]/" => "o", |
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 | |
function valor_extenso($valor=0, $maiusculas=false) | |
{ | |
// verifica se tem virgula decimal | |
if (strpos($valor,",") > 0) | |
{ | |
// retira o ponto de milhar, se tiver | |
$valor = str_replace(".","",$valor); | |
// troca a virgula decimal por ponto decimal |
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
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{REQUEST_URI} !^/blog.* | |
RewriteCond %{REQUEST_URI} !-f | |
RewriteRule ^$ app/webroot/ [L] | |
RewriteCond %{REQUEST_URI} !^/blog.* | |
RewriteCond %{REQUEST_URI} !-d | |
RewriteRule (.*) app/webroot/$1 [L] |
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
#!/bin/sh | |
# Just copy and paste the lines below (all at once, it won't work line by line!) | |
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY! | |
function abort { | |
echo "$1" | |
exit 1 | |
} | |
set -e |
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 | |
/** | |
* @todo CakePHP Permissions Array by Kevin Wentworth (Saco Design, Inc.) | |
* @todo Handles retrieving all ACL Permissions and storing them in an array. | |
* @todo Comments and bug reports welcome at kevin at sacode sign dot com | |
* | |
* @licensed Licensed under UYOR (Use at Your Own Risk) | |
* @link http://www.mainelydesign.com/blog/view/getting-all-acl-permissions-in-one-lookup-cakephp-1-3#null | |
*/ |
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 | |
class Minhamodel extends AppModel{ | |
//Primeira opção, caso nunca mude o "alias" da model | |
public $virtualFields = array( | |
'data_formatada'=>"DATE_FORMAT(Minhamodel.data,'%d/%m/%Y')", | |
); | |
//Alternativa caso mude o "alias" da model, melhor opção | |
public function __construct($id=false,$table=null,$ds=null){ |
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
# when I tried to start postgres, I had an error telling me there were no postgres clusters created | |
# so I had to create one using the `pg_createcluster` command, like the following | |
pg_createcluster 9.1 main --start | |
#after creating the cluster, it will start the server because of `--start` | |
#so I had to change to postgresql user | |
sudo su - postgres | |
#to change it's pasword, doing `psql -d <database_name> -U <username> | |
psql -d postgres -U postgres |
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
/** | |
* Metódo para válidar um CPF | |
* @param String $cpf | |
* @return boolean | |
*/ | |
public function validCPF($cpf) { | |
// determina um valor inicial para o digito $d1 e $d2 | |
// pra manter o respeito ;) | |
$d1 = 0; | |
$d2 = 0; |