Created
February 27, 2016 14:32
-
-
Save cakephp-tutorial/9bd0d25e8c4a95053cac 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)', | |
'createdIta' => 'DATE_FORMAT(Contact.created,"%d/%m/%Y")' | |
); | |
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