# |
Aug 27th 2019, 13:34 |
spriz |
dereuromark do you mostly `->get()`, even with conditions over `->find()->where()->firstOrFail()`? :slightly_smiling_face: |
# |
Aug 27th 2019, 13:30 |
np |
ok, thanks ppl :slightly_smiling_face: |
# |
Aug 27th 2019, 13:30 |
spriz |
Ah whack, `->find()` kinda kills that :) |
# |
Aug 27th 2019, 13:30 |
dereuromark |
If you try it you will easily find the answer yourself :slightly_smiling_face: |
# |
Aug 27th 2019, 13:30 |
spriz |
`@method \StateMachine\Model\Entity\StateMachineItemState|null first($finder, $options = [])` |
# |
Aug 27th 2019, 13:29 |
spriz |
@dereuromark why is `first()` not a part of that? :) |
# |
Aug 27th 2019, 13:27 |
dereuromark |
You will see that it annotates all the right types everywhere then for you and your tooling ( https://github.com/spryker/cakephp-statemachine/blob/master/src/Model/Table/StateMachineItemStatesTable.php#L21 etc). Easily possible to get to phpstan level 7 with these approaches then as I did for my plugins. |
# |
Aug 27th 2019, 13:26 |
dereuromark |
use ModelAwareTrait and IdeHelper annotations. that fixes it by design. You arent supposed to use the static access. |
# |
Aug 27th 2019, 13:25 |
np |
@spriz yeah https://scrutinizer-ci.com |
# |
Aug 27th 2019, 13:23 |
spriz |
so you could put something like `/** @var \App\Model\Entity\VendorProduct $integrationSettings */` above it probably - replacing `VendorProduct` with your entity class and `$integrationSettings` with `$request` |
# |
Aug 27th 2019, 13:23 |
np |
``` $requestsTable = TableRegistry::getTableLocator()->get('Requests'); $request = $requestsTable->get($request_id, ['contain' => ['Orders', 'Appointments']]);` $request->created->format('Y-m-d'); ``` |
# |
Aug 27th 2019, 13:22 |
spriz |
so that parser do not know what `$request` is but that it implements `EntityInterface` which does not have a `created` property |
# |
Aug 27th 2019, 13:21 |
spriz |
@np I guess that's from some CI tool or something? phpcs? phpstan? |
# |
Aug 27th 2019, 13:21 |
dereuromark |
Surrounding code is vital to give a good answer. |
# |
Aug 27th 2019, 13:17 |
neon1024 |
Knew if I asked, I’d find it! https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-additional-data-to-the-join-table |
# |
Aug 27th 2019, 13:16 |
neon1024 |
I’ve lost the bit in the book about how to create form fields for writing to`_joinData` |
# |
Aug 27th 2019, 13:15 |
np |
Can you give one example? |
# |
Aug 27th 2019, 12:57 |
dereuromark |
You need to give proper context here. |
# |
Aug 27th 2019, 12:47 |
np |
Hello, `'orderDate' => $request->created->format('Y-m-d'),` > Accessing created on the interface Cake\Datasource\EntityInterface suggest that you code against a concrete implementation. How to fix this? |
# |
Aug 27th 2019, 12:32 |
vossen.steven |
https://github.com/dereuromark/cakephp-tools/blob/master/docs/Entity/Enum.md |
# |
Aug 27th 2019, 12:31 |
conehead |
https://www.dereuromark.de/2010/06/24/static-enums-or-semihardcoded-attributes/ |
# |
Aug 27th 2019, 12:31 |
conehead |
@turkles Maybe have a look at this |
# |
Aug 27th 2019, 12:24 |
turkles |
Howdy, if I have a set of values (like.. V. Poor, Poor, Avg, Good, V.Good) is there an easy way to show these as text but save in my db as a tinyint where my model switches them as it sets/gets? |
# |
Aug 27th 2019, 10:45 |
neon1024 |
Ah, actually, I’ll add a condition to the association |
# |
Aug 27th 2019, 10:44 |
neon1024 |
When I am using `belongsToMany()` with `through` option, how can I sort on a field in the through table? Do I need to expand the association to belongsTo and hasMany? |
# |
Aug 27th 2019, 09:04 |
koeller |
Nevermind, after some more testint I found it. The key config is not necessary, just had to pass the key of my actual configuration to change, like: ``` $this->Crud->mapAction('edit', [ 'className' => '\App\Crud\Action\Data\EditAction', 'MessageCenter' => Configure::read('TableMessageCenter.Table') ]); ```` |
# |
Aug 27th 2019, 08:52 |
slackebot2 |
<koeller> |
# |
Aug 27th 2019, 08:46 |
challgren |
Well its really late evening, here |
# |
Aug 27th 2019, 08:28 |
conehead |
good mornin |
# |
Aug 27th 2019, 08:27 |
challgren |
morning |
# |
Aug 27th 2019, 08:03 |
vossen.steven |
o/ |
# |
Aug 27th 2019, 07:57 |
neon1024 |
Morning all :wave: |
# |
Aug 27th 2019, 01:58 |
challgren |
https://github.com/cakephp/debug_kit/releases/tag/3.20.2 |
# |
Aug 27th 2019, 01:58 |
ricksaccous |
Awesome ;) |
# |
Aug 27th 2019, 01:57 |
challgren |
@ricksaccous DebugKit is fixed now |
# |
Aug 26th 2019, 21:57 |
slackebot2 |
ProductsTable and Product respectively, which does not seem to be the case I, for example, use Table->getAlias() and Entity->getSource() and both of these return RecommendedProducts instead of Products, meaning I get errors due to unkown table/entity. Now my question is how would I setup the relationship properly to get the results I need, or am I going about this the wrong way? An example of my use case is that I have meta_tags that have a foreign_id |
# |
Aug 26th 2019, 21:57 |
slackebot2 |
$itemTable = TableRegistry::getTableLocator()->get($this->getSource()); $metaTags = $metaTagsTable->find() ->cache(sprintf('meta_tags_%s_%s', $itemTable->getAlias(), $this->id), '_meta_tags_') ->where([ $metaTagsTable->aliasField('foreign_id') => $this->id, $metaTagsTable->aliasField('foreign_model') => $itemTable->getAlias(), ]) |
# |
Aug 26th 2019, 21:57 |
slackebot2 |
->first(); if ($metaTags !== null) { $this->_metaTags = $metaTags->value; } } return $this->_metaTags; } ``` |
# |
Aug 26th 2019, 21:57 |
slackebot2 |
+ foreign_model, which I fetch and cache in my default entity, but since my Table->getAlias() and Entity->getSource() return the wrong values I can't get the right meta tag ``` DefaultEntity /** @var string|null */ private $_metaTags; /** * @return string|null */ protected function _getMetaTags() { if ($this->_metaTags === null) { $metaTagsTable = TableRegistry::getTableLocator()->get('MetaTags'); |
# |
Aug 26th 2019, 21:57 |
vossen.steven |
Hey guys, got a question about self referencing BelongsToMany I have Products with a BelongsToMany to RecommendedProducts ``` ProductsTable $this->belongsToMany('RecommendedProducts', [ 'className' => 'Products', 'joinTable' => 'products_recommended_products', ]); ``` Now on to the problem, for me it seemed logical that both the RecommendedProductsTable and RecommendedProduct would reference |
# |
Aug 26th 2019, 18:52 |
ricksaccous |
i just threw in an issue |