# |
Dec 18th 2019, 11:31 |
gianmarxgagliardi |
I defined this function in the model> entity> Trainer.php |
# |
Dec 18th 2019, 11:31 |
neon1024 |
You’re accessing an entity which is a php class |
# |
Dec 18th 2019, 11:30 |
neon1024 |
As before, it would only work with something which uses the Hash library in the background |
# |
Dec 18th 2019, 11:29 |
gianmarxgagliardi |
oddly I saw it worked compared to `$trainer->full_name` |
# |
Dec 18th 2019, 11:28 |
gianmarxgagliardi |
that was a typo `$trainer.full_name` |
# |
Dec 18th 2019, 11:27 |
neon1024 |
Unless you did lots of Javascript or something and got confused I suppose |
# |
Dec 18th 2019, 11:26 |
neon1024 |
This was another reason why I asked about previous PHP experience. Most people would see that `$trainer.full_name` this isn’t valid PHP |
# |
Dec 18th 2019, 11:26 |
gianmarxgagliardi |
I followed this guide https://book.cakephp.org/3/en/orm/entities.html#creating-virtual-fields. |
# |
Dec 18th 2019, 11:25 |
dereuromark |
you need to use valid PHP here. What is the value of $trainer? wrap it in " or alike. |
# |
Dec 18th 2019, 11:23 |
gianmarxgagliardi |
> if I put `$trainer->full_name` return > `*Notice* (8): Undefined variable: trainer [*APP/Controller\SeasonTrainersController.php*, line *62*]` > `*Notice* (8): Trying to get property 'full_name' of non-object [*APP/Controller\SeasonTrainersController.php*, line *62*]` |
# |
Dec 18th 2019, 11:19 |
dereuromark |
$trainer.full_name is not valid PHP |
# |
Dec 18th 2019, 11:17 |
gianmarxgagliardi |
@dereuromark I'm confused ? what do you mean ? |
# |
Dec 18th 2019, 11:16 |
gianmarxgagliardi |
`$trainersUnmated=$this->SeasonTrainers->Trainers->find('list',['keyField' => 'id', 'valueField' =>$trainer.full_name])->notMatching('SeasonTrainers');` |
# |
Dec 18th 2019, 11:16 |
gianmarxgagliardi |
in model `protected function _getFullName()` `{` `return $this->cognome . ' ' . $this->nome;` `}` |
# |
Dec 18th 2019, 11:15 |
dereuromark |
avoid using custom constants :) |
# |
Dec 18th 2019, 11:14 |
gianmarxgagliardi |
it works but it gives me some warnings ```Warning (2): Use of undefined constant full_name - assumed 'full_name' (this will throw an Error in a future version of PHP) [APP/Controller\SeasonTrainersController.php, line 62]``` |
# |
Dec 18th 2019, 11:09 |
gianmarxgagliardi |
it's works thanks |
# |
Dec 18th 2019, 10:54 |
challgren |
Virtual fields would be your friend |
# |
Dec 18th 2019, 10:54 |
challgren |
@gianmarxgagliardi https://book.cakephp.org/3/en/orm/entities.html#creating-virtual-fields |
# |
Dec 18th 2019, 10:53 |
gianmarxgagliardi |
in this way it returns the fields "name" and "surname" divided by a semicolon to avoid this I have to write a separate function or there is another way `$trainersUnmated=$this->SeasonTrainers->Trainers->find('list',['keyField' => 'id','valueField' =>['name','surname']])->notMatching('SeasonTrainers');` the result I get is e.g. `John; Milton` but I would like `John Milton` |
# |
Dec 18th 2019, 10:45 |
javier.villanueva |
thanks! |
# |
Dec 18th 2019, 10:43 |
challgren |
```$query = $articles->find()->contain('Comments', function (Query $q) { return $q->find('approved')->find('popular'); });``` |
# |
Dec 18th 2019, 10:41 |
javier.villanueva |
I have a custom finder in a table "Tasks" , Tasks belongsTo Users. If I find $this->Users->find()->contain(['Tasks']); Can I apply my custom finder ? |
# |
Dec 18th 2019, 10:37 |
rochasmarcelo |
remove composer.lock and update composer.json |
# |
Dec 18th 2019, 10:33 |
SvenBuis |
Yes, I will if I find any :) . To bad some of the 3rd party plugins I used are no longer maintained. Some I already had to fork to make them 3.8 compatible. If I find the time I will probably write my own plugin for those |
# |
Dec 18th 2019, 10:32 |
challgren |
And if the plugin doesn’t support cake 4.x help the community out and do a PR for 4.x support. Most 3.8 code should support 4.x without an issue |
# |
Dec 18th 2019, 10:31 |
SvenBuis |
So it might be possible to update cake and the plugin at once, that would be the easiest way hehe |
# |
Dec 18th 2019, 10:31 |
SvenBuis |
Okay. I will give that a go |
# |
Dec 18th 2019, 10:31 |
neon1024 |
..and `composer outdated -D` |
# |
Dec 18th 2019, 10:30 |
neon1024 |
Also try `composer why` and `composer why-not` |
# |
Dec 18th 2019, 10:30 |
neon1024 |
I’d probably hunt the plugins on Packagist.org to see which version constraints are, and updated my `composer.json` file with the new versions and then try updating |
# |
Dec 18th 2019, 10:30 |
jotpe |
Yes |
# |
Dec 18th 2019, 10:30 |
SvenBuis |
So, basically remove plugins, update Cake, install (newer versions) of the plugins |
# |
Dec 18th 2019, 10:29 |
jotpe |
I would try to remove the plugins first and upgrade the core app. Then update the plugins one after the other |
# |
Dec 18th 2019, 10:28 |
challgren |
You might need to specify dev-4.x for the plugin version |
# |
Dec 18th 2019, 10:28 |
SvenBuis |
Yes, but in this case the plugin has a 4.x branche. But updating to that branche gives the error that I have Cake 3.x installed, updating to Cake 4 gives the error that the plugin requires 3.x |
# |
Dec 18th 2019, 10:27 |
pieceof |
and here ima stuck |
# |
Dec 18th 2019, 10:27 |
challgren |
Over time most will update or die off |
# |
Dec 18th 2019, 10:27 |
challgren |
@svenbuis it really depends on the plugins, I know a lot dont have 4.x support just yet |
# |
Dec 18th 2019, 10:26 |
pieceof |
in my case they were lookin for someone with cakephp but i had only a bit of symfony got hired by luck i guess, there were a senior developing a crm with cake they tested several frameworks found cake to be out of the box more secure than the rest in that time |
# |
Dec 18th 2019, 10:26 |
SvenBuis |
This seems to me like a ‘chicken-egg’ problem. So I would like your advise, what is the best way to solve this. |