Skip to content

Instantly share code, notes, and snippets.

@cakephp-tutorial
Created February 27, 2016 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cakephp-tutorial/8e51584f80838e9181fb to your computer and use it in GitHub Desktop.
Save cakephp-tutorial/8e51584f80838e9181fb to your computer and use it in GitHub Desktop.
<?php
# /app/Model/Contact.php
class Contact extends AppModel {
public $displayField = 'fullname';
public $virtualFields = array(
'fullname' => 'CONCAT(Contact.name, " ", Contact.surname)',
'withCompany' => 'CONCAT(Contact.name, " ", Contact.surname, " - ", Contact.company',
'bySurname' => 'CONCAT(Contact.surname, " ", Contact.name)',
);
public function getUserInfos($id) {
$this->virtualFields['userInfos'] = 'CONCAT(Contact.name, " ", Contact.surname, " - iscritto il ", Contact.created';
return $this->findById($id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment