Direcciones búsqueda empleo

http://www.infojobs.com/

http://www.pagepersonnel.es/index.html

https://es.linkedin.com/nhome/

Para freelance:

http://www.nubelo.com/

https://freelance.infojobs.net/

Reuniones para hacer contactos:

http://www.meetup.com/

Nuevas funcionalidades rest client

Añadimos esto en la vista index:

 <li><?php echo $this->Html->link('Ver producto con ID 1', array('controller' => 'cliente', 'action' => 'rest_view', 1)); ?></li>
<li><?php echo $this->Html->link('Añadir producto', array('controller' => 'cliente', 'action' => 'rest_add')); ?></li>
<li><?php echo $this->Html->link('Actualizar producto 2', array('controller' => 'cliente', 'action' => 'rest_edit', 2)); ?></li>
<li><?php echo $this->Html->link('Borrar producto 3', array('controller' => 'cliente', 'action' => 'rest_delete', 3)); ?></li>

Y esto en el controlador:

  public function rest_view($id){
 
 $link = $this->url.'rest_productos/'.$id.'.json';
 
 $data = null;
 $httpSocket = new HttpSocket();
 $response = $httpSocket->get($link, $data );
 $this->set('response_code', $response->code);
 $this->set('response_body', $response->body);
 
 $this -> render('/Cliente/respuesta');
 }

 public function rest_add(){
 
$link=$this->url."rest_productos.json";
 $data = null;
 $httpSocket = new HttpSocket();
 $data['Producto']['nombre'] = 'Nuevo producto';
 $data['Producto']['referencia'] = 'Nueva referencia';
 //$data['Phone']['name'] = 'New Phone Description';
 $response = $httpSocket->post($link, $data );
 $this->set('response_code', $response->code);
 $this->set('response_body', $response->body);
 
 $this -> render('/Cliente/respuesta');
 }
 public function rest_edit($id){
 
 $link = $this->url.'rest_productos/'.$id.'.json';
 $data = null;
 $httpSocket = new HttpSocket();
 $data['Producto']['nombre'] = 'Actualizado producto';
 $data['Producto']['referencia'] = 'Actualizada referencia';
 $response = $httpSocket->put($link, $data );
 $this->set('response_code', $response->code);
 $this->set('response_body', $response->body);
 
 $this -> render('/Cliente/respuesta');
 }
 
 public function rest_delete($id){
 
 // remotely post the information to the server
 $link = $this->url.'rest_productos/'.$id.'.json';
 $data = null;
 $httpSocket = new HttpSocket();
 $response = $httpSocket->delete($link, $data );
 $this->set('response_code', $response->code);
 $this->set('response_body', $response->body);
 
 $this -> render('/Cliente/respuesta');
 }

Subir archivos en cakephp

Teniendo bien configurado el formulario, debemos tener lo siguiente en el add del controlador:

  if (
 !empty($this->request->data['Entrada']['documento']['tmp_name'])
 && is_uploaded_file($this->request->data['Entrada']['documento']['tmp_name'])
) {
 // Strip path information
 $filename = basename($this->request->data['Entrada']['documento']['name']); 
 move_uploaded_file(
 $this->data['Entrada']['documento']['tmp_name'],
 WWW_ROOT . DS . 'documentos' . DS . $filename
 );
}

Componente frase

Dentro de componentes crear un archivo llamado:

UtilidadesComponent.php

class UtilidadesComponent extends Component {

 public $components = array();
 public function frase(){
 $spam=array('Muy bueno','Estupenda entrada','Eres un crack','Lo mejor que he leído','Ole y ole','Me ha gustado','Bastante bueno','Muy interesante','De gran utilidad','Está bastante bien','Me ha hecho pensar');
 $com=$spam[rand(0,count($spam)-1)];
 return $com;
 }
 

}

Validación de datos

Cuando creamos un modelo tenemos la posibilidad de introducir validación de datos. Se indica con la variable $validate:

class User extends AppModel {
    var $name = 'User';
    var $validate = array(
        'login' => 'alphaNumeric',
        'email' => 'email',
        'born' => 'date'
    );
}

Las reglas de validación pueden ser complejas:

class User extends AppModel {
    var $name = 'User';
    var $validate = array(
        'login' => array(
            'alphaNumeric' => array(
                'rule' => 'alphaNumeric',
                'required' => true,
                'message' => 'Sólo letras y números'
                ),
            'between' => array(
                'rule' => array('between', 5, 15),
                'message' => 'Entre 5 y 15 caracteres'
            )
        ),
        'password' => array(
            'rule' => array('minLength', '8'),
            'message' => 'Largo mínimo de 8 caracteres'
        ),
        'email' => 'email',
        'born' => array(
            'rule' => 'date',
            'message' => 'Ingrese una fecha válida',
            'allowEmpty' => true
        )
    );
}

El formato general es el siguiente:

var $validate = array(
    'fieldName1' => array(
        'rule' => 'ruleName', // ó: array('ruleName', 'param1', 'param2' ...)
        'required' => true,
        'allowEmpty' => false,
        'on' => 'create', // ó: 'update'
        'message' => 'Su mensaje de error'
    )
);

Cada campo puede tener más de una regla:

var $validate = array(
    'login' => array(
        'alphanumeric' => array(
            'rule' => 'alphaNumeric',
            'message' => 'Se permiten sólo letras y números',
            'last' => true
         ),
        'minlength' => array(
            'rule' => array('minLength', '8'),
           'message' => 'Largo mínimo de 8 caracteres'
        ),
    )
);

Una lista de todas las reglas incorporadas en el núcleo se puede encontrar aquí:

Data validation in cakephp

Tipos de Relaciones

Los cuatro tipos de relaciones en CakePHP son: hasOne, hasMany, belongsTo y hasAndBelongsToMany(HABTM), “tiene un”, “tiene muchos”, “pertenece a” y “tiene y pertenece a muchos”, respectivamente.

Relación Tipo de Asociación Ejemplo
uno a uno hasOne (“tiene un”) Una usuario tiene un perfil.
uno a muchos hasMany (“tiene muchos”) Un usuario puede tener múltiples entradas.
muchos a uno belongsTo (“pertenece a”) Muchas entradas pertenecen a un usuario.
muchos a muchos hasAndBelongsToMany (“tiene y pertenece a muchos”) Las entradas tienen, y pertenecen a, muchas etiquetas.

Ejemplos:

class Usuario extends AppModel {
    var $name = 'Usuario';
    var $hasOne = 'Perfil';
}
class Perfil extends AppModel {
    var $name = 'Perfil';
    var $belongsTo = 'Usuario';
}

Específico:

class Perfil extends AppModel {
    var $name = 'Perfil';
    var $belongsTo = array(
        'Usuario' => array(
            'className'    => 'Usuario',
            'foreignKey'   => 'usuario_id'
        )
    );
}
class Usuario extends AppModel {
    var $name = 'Usuario';
    var $hasMany = 'Comentario';
}

Específica:

class Usuario extends AppModel {
    var $name = 'Usuario';
    var $hasMany = array(
        'Comentario' => array(
            'className'     => 'Comentario',
            'foreignKey'    => 'usuario_id',
            'conditions'    => array('Comentario.estado' => '1'),
            'order'    => 'Comentario.created DESC',
            'limit'        => '5',
            'dependent'=> true
        )
    );
}
class Receta extends AppModel {
    var $name = 'Receta';
    var $hasAndBelongsToMany = array(
        'Etiqueta' =>
            array('className'            => 'Etiqueta',
                 'joinTable'              => 'etiquetas_recetas',
                 'foreignKey'             => 'receta_id',
                 'associationForeignKey'  => 'etiqueta_id',
                'with'                   => '',
                'conditions'             => '',
                'order'                  => '',
                'limit'                  => '',
                'unique'                 => true,
                'finderQuery'            => '',
                'deleteQuery'            => '',
                'insertQuery'            => ''
            )
        );
}