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\Model\Table\Extra; | |
use Cake\ORM\Query | |
trait DatesTrait{ | |
public function findSeteDias(Query $query,array $options){ | |
$alias = $this->alias(); | |
$query->where([ | |
"{$alias}.data >"=>date('Y-m-d',strtotime("-7 days")), |
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
angular.module('App').directive('gallery',function(){ | |
return { | |
templateUrl:'/admin/angular/templates/gallery.html', | |
replace:true, | |
scope:{ | |
gallery:'=' | |
}, | |
controller:['$scope','$http',function(scope,http){ | |
scope.button = 'Selecione uma imagem'; |
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 NoticiasController extends AppController | |
{ | |
public function read() | |
{ | |
$slug = $this->request->param('noticia'); //Pega o slug da notícia vindo do router... | |
$noticia = $this->Noticia->findBySlug($slug); //Pega a notícia baseada no slug | |
$this->set(compact('noticia')); //Envia pra view | |
} |
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 MeuController extends AppController | |
{ | |
public function busca($txt){ | |
$resultados = $this->Model->find('all',array( | |
'fields'=>array('*',"(MATCH(Model.title,Model.content,Model.campo_adicional) AGAINST ('{$txt}')) as relevancia"), | |
'conditions'=>array('relevancia > 0'), | |
'order'=>'relevancia DESC', | |
)); |
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() { | |
var script, | |
scripts = document.getElementsByTagName('script')[0]; | |
function load(url) { | |
script = document.createElement('script'); | |
script.async = true; | |
script.src = url; | |
scripts.parentNode.insertBefore(script, scripts); |