Created
February 27, 2016 14:31
-
-
Save cakephp-tutorial/8e51584f80838e9181fb to your computer and use it in GitHub Desktop.
This file contains 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 | |
# /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