Skip to content

Instantly share code, notes, and snippets.

@TiuTalk
Forked from patrickmaciel/Core.php
Created April 4, 2012 19:47
Show Gist options
  • Save TiuTalk/2305075 to your computer and use it in GitHub Desktop.
Save TiuTalk/2305075 to your computer and use it in GitHub Desktop.
FrontEndController.php
<?php
App::uses('AppController','Controller');
class FrontEndController extends AppController {
public $uses = array('Categoria', 'Modelo', 'Cliente', 'Marca', 'Anuncio');
public $components = array('Buscas');
public $helpers = array('Imagem', 'Number', 'Media', 'Cache');
public $cacheAction = array(
'index' => '10 minutes'
);
public function index(){
// $this->cacheAction = '1 minutes';
$this->set('title_for_layout','Home');
//Busca veículos em destaque
$destaques = $this->Anuncio->findThumbsAtivos('all');
$buscados = $this->Anuncio->findMaisBuscados(6);
// // $destaques = $this->Anuncio->findThumbsAtivos('all');
// $cacheConfig = 'anuncios';
// $destaques = Cache::read('thumbsAtivos', $cacheConfig);
// if (!$destaques) {
// $destaques = $this->Anuncio->findThumbsAtivos('all');
// Cache::write('thumbsAtivos', $destaques, $cacheConfig);
// }
$this->set(array_merge(
$this->Veiculo->getBuscaRapida(),
$this->Buscas->getBuscaLojas(),
compact('destaques', 'buscados')
));
}
public function painel_index(){
$userId = $this->Auth->user('id');
$cliente = $this->Cliente->find('first',array(
'fields' => array('Cliente.nome'),
'conditions' => array('Usuario.id'=>$userId)
));
$Anuncio = $this->Cliente->Contrato->Anuncio;
$anuncios = $Anuncio->find('all',array(
'contain' => array(
'Contrato' => array(
'Plano'
),
'Veiculo' => array(
'Versao' => array(
'Modelo' => array(
'Marca'
)
),
'Categoria'
)
),
'conditions' => array(
'Contrato.cliente_id' => $cliente['Cliente']['id'],
'Anuncio.created >=' => date('Y-m-d 00:00:00')
)
));
$anuncios = $Anuncio->validarAtivos($anuncios);
$title_for_layout = 'Painel do anunciante';
$this->set(compact('anuncios','title_for_layout'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment