# |
Mar 6th 2018, 15:20 |
slackebot |
'order' => ['UnqualifiedLead.id' => 'desc'] ])``` |
# |
Mar 6th 2018, 15:20 |
popperz0r |
```$unqualified_leads_table = $this->UnqualifiedLead->find('all',[ 'fields' => ['id', 'name', 'user_id', 'User.first_name', 'User.last_name', 'User.full_name' => $this->UnqualifiedLead->query()->func()->concat(['User.first_name', ' ', 'User.last_name']), 'LeadType.label', 'Email.email', 'Phone.number', 'City.city_name'], 'contain' => ['User', 'Phone', 'Email', 'City', 'Company', 'LeadType'], |
# |
Mar 6th 2018, 15:20 |
popperz0r |
@jeremyharris im not able to fetch results now :) |
# |
Mar 6th 2018, 15:19 |
Es0teric |
jeremyharris, sure... give me a sec |
# |
Mar 6th 2018, 15:17 |
jeremyharris |
can you provide a minimal example of what’s happening? |
# |
Mar 6th 2018, 15:15 |
Es0teric |
how do i get past that while maintaining the multidimensional data? |
# |
Mar 6th 2018, 15:15 |
Es0teric |
i have this problem with returning array types in cakephp 2.x -- now I have a multidimensional array in a method and i want to use the return value in a variable... but for some reason it keeps breaking the app silently |
# |
Mar 6th 2018, 15:14 |
jeremyharris |
my example assumed you were on the table |
# |
Mar 6th 2018, 15:14 |
jeremyharris |
$this->UnqualifiedLead->query() |
# |
Mar 6th 2018, 15:14 |
popperz0r |
```Call to undefined method App\Controller\Api\UnqualifiedLeadController::query()``` |
# |
Mar 6th 2018, 15:13 |
jeremyharris |
what do you mean? |
# |
Mar 6th 2018, 15:13 |
jeremyharris |
you can use it in that list |
# |
Mar 6th 2018, 15:13 |
popperz0r |
any change to set it inside fields? |
# |
Mar 6th 2018, 15:13 |
popperz0r |
i can see i have to put it outside |
# |
Mar 6th 2018, 15:13 |
slackebot |
['UnqualifiedLead.id' => 'desc'] ])->where(AuthorizationComponent::getUserAuthorizedLeadAccessCondition($this->Auth->User())['conditions'], AuthorizationComponent::getUserAuthorizedLeadAccessCondition($this->Auth->User())['value_type']) ->andWhere($include_conditions);``` |
# |
Mar 6th 2018, 15:13 |
popperz0r |
``` $unqualified_leads_table = $this->UnqualifiedLead->find('all',[ 'fields' => ['id', 'name', 'user_id', 'User.first_name', 'User.last_name', 'User.full_name' => $this->query()->func()->concat(['first_name', ' ', 'last_name']), 'LeadType.label', 'Email.email', 'Phone.number', 'City.city_name'], 'contain' => ['User', 'Phone', 'Email', 'City', 'Company', 'LeadType'], 'order' => |
# |
Mar 6th 2018, 15:13 |
popperz0r |
can i adjust it to this? |
# |
Mar 6th 2018, 15:12 |
jeremyharris |
in 2.x, virtual fields were actual SQL snippets like this, while in 3.x they are simply calculated properties on the entity object |
# |
Mar 6th 2018, 15:11 |
jeremyharris |
``` $query = $this->find() ->select(['full_name' => $this->query()->func()->concat(['first_name', ' ', 'last_name']); ``` |
# |
Mar 6th 2018, 15:10 |
jeremyharris |
something like this: |
# |
Mar 6th 2018, 15:09 |
jeremyharris |
instead, you’ll have to build it as an alias field via the orm |
# |
Mar 6th 2018, 15:09 |
jeremyharris |
you cannot in the class 2.x sense do it the same way. a virtual field on the entity is within PHP and calculated by PHP, and has nothing to do with SQL |
# |
Mar 6th 2018, 15:08 |
popperz0r |
now i need to make a request of a string which should query full_name LIKE '%string%' |
# |
Mar 6th 2018, 15:08 |
popperz0r |
is concats first_name and last_name |
# |
Mar 6th 2018, 15:08 |
popperz0r |
i created a virtual property inside User Entity named full_name |
# |
Mar 6th 2018, 15:07 |
jeremyharris |
perhaps an example of what you’re looking for would help us? |
# |
Mar 6th 2018, 15:06 |
popperz0r |
anyone use this? |
# |
Mar 6th 2018, 15:06 |
popperz0r |
it is killing me |
# |
Mar 6th 2018, 15:06 |
popperz0r |
im still strugling with virtual properties conditions |
# |
Mar 6th 2018, 15:06 |
popperz0r |
hi everyone |
# |
Mar 6th 2018, 14:17 |
neon1024 |
Afternoon everyone |
# |
Mar 6th 2018, 12:54 |
savant |
night all |
# |
Mar 6th 2018, 12:46 |
makallio85 |
Thanks for your time! Clarified things for me. |
# |
Mar 6th 2018, 12:46 |
makallio85 |
Okay. Now I get it. |
# |
Mar 6th 2018, 12:46 |
savant |
I think thats an anti-pattern |
# |
Mar 6th 2018, 12:46 |
savant |
I dont like querying the database from within the entity |
# |
Mar 6th 2018, 12:44 |
makallio85 |
Do we mean here by "virtual value", something that does lazyloading or something that processes some other data that entity already has? And that should be considered as antipattern? |
# |
Mar 6th 2018, 12:43 |
makallio85 |
Cool. So if i add method getPhoneNumber() to contact that iterates just what entity already holds we are all good here. I just got little bit confused of virtual value => anti pattern thoughts you said. |
# |
Mar 6th 2018, 12:41 |
savant |
accessing data you have access to already - and throwing exceptions when its missing - is good |
# |
Mar 6th 2018, 12:41 |
savant |
querying from the method is bad |
# |
Mar 6th 2018, 12:41 |
makallio85 |
Aaa okay. So you mean, i can have public method in entity, but virtual value is bad pattern? |