# |
Apr 26th 2017, 00:14 |
elcms |
A preview for an "index" request is available here : https://codepen.io/mtancoigne/pen/dWOJqj |
# |
Apr 26th 2017, 00:14 |
elcms |
I started a cheatsheet for CakePHP events; i'm searching for motivated people to help me in this... |
# |
Apr 26th 2017, 00:12 |
elcms |
Hi ! |
# |
Apr 25th 2017, 23:18 |
jeremyharris |
@cpierce see: https://book.cakephp.org/3.0/en/views/helpers/form.html#adding-additional-template-variables-to-templates |
# |
Apr 25th 2017, 23:16 |
jeremyharris |
@cpierce I know it’s been a while, but usually what I do is `class="my-class {{class}}"` in the template, then set the class var with `'templateVars' => ['class' => 'other-class']` |
# |
Apr 25th 2017, 21:21 |
cpierce |
if i'm using a template how can I use class="something" and still put the class that is passed ot it in as well? |
# |
Apr 25th 2017, 21:12 |
losted |
hehe |
# |
Apr 25th 2017, 21:11 |
jeremyharris |
oh man these cake 2 docs take me back |
# |
Apr 25th 2017, 21:10 |
jeremyharris |
losted so Credit belongsTo User hasOne UserProfile, so perhaps `'contain' => ['User.UserProfile']`, see: https://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html#containing-deeper-associations |
# |
Apr 25th 2017, 21:07 |
jeremyharris |
I think my relationship are fixed now but I'm still unsure how to use the "contain" to fetch my UserProfile From the Credit find() ? |
# |
Apr 25th 2017, 21:05 |
jeremyharris |
np! |
# |
Apr 25th 2017, 21:04 |
RingoK |
Again, very thanks. This is something i was looking for. |
# |
Apr 25th 2017, 21:03 |
RingoK |
I will take a look at it now |
# |
Apr 25th 2017, 21:03 |
RingoK |
thanks jeremyharris. That was the kind of direction i was looking for. |
# |
Apr 25th 2017, 21:03 |
jeremyharris |
(I just updated and dumped the test case for you) |
# |
Apr 25th 2017, 21:01 |
jeremyharris |
of course, you can mock specific methods on the IO if you want, I just discard all output in my case |
# |
Apr 25th 2017, 21:01 |
jeremyharris |
RingoK you can use the core tests as examples. In my case, it’s pretty basic setup and I just call the sub command methods directly. setUp is just this: https://gist.github.com/jeremyharris/c7af936ee44f26df3f3f99ce4219d7eb |
# |
Apr 25th 2017, 20:59 |
RingoK |
Hello guys, can someone point me in the right direction for writing unit tests for Shell's? Die official book doesent seem to have anything to say about it :-) And it seems also a challange for our friend google (or is it me?) |
# |
Apr 25th 2017, 20:51 |
jeremyharris |
then explicitly contain only data you need on each find call |
# |
Apr 25th 2017, 20:51 |
jeremyharris |
yes, it’s vital. also, turn recursive off day 1 |
# |
Apr 25th 2017, 20:50 |
losted |
maybe it's the contain that I've been missing all along... I'll try that |
# |
Apr 25th 2017, 20:47 |
jeremyharris |
there’s an example of User hasOne Profile (similar to your first case) |
# |
Apr 25th 2017, 20:46 |
jeremyharris |
see here: https://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasone |
# |
Apr 25th 2017, 20:46 |
losted |
ok |
# |
Apr 25th 2017, 20:46 |
jeremyharris |
okay remember that bindModel is a one time only thing. I suggest using permanent associations in your models instead, and using contain |
# |
Apr 25th 2017, 20:46 |
losted |
for the UserProfile, do I enter my stuff in there of I need another bindModel like : $this->Credit->User->bindModel(...) ? |
# |
Apr 25th 2017, 20:45 |
losted |
https://pastebin.com/raw/xKgN1Y4r |
# |
Apr 25th 2017, 20:45 |
losted |
here's where I'm at right now |
# |
Apr 25th 2017, 20:45 |
jeremyharris |
if I’m understanding right: User hasOne UserProfile and User hasMany Credit and Credit belongsTo User and UserProfile belongsTo User |
# |
Apr 25th 2017, 20:44 |
jeremyharris |
so in this case, your user profile association would be included in the original User hasOne relationship |
# |
Apr 25th 2017, 20:43 |
jeremyharris |
losted generally you set up all of the relationships (e.g., define your belongsTo array that contains ALL associations) and use contain to select what data to include in the find() |
# |
Apr 25th 2017, 20:41 |
jeremyharris |
I tried your method and work well with my initial Models but I still don't get how to make my UserProfile relationship |
# |
Apr 25th 2017, 20:37 |
jeremyharris |
:+1: |
# |
Apr 25th 2017, 20:37 |
dan223 |
Ahh. That is what I am looking for. Thank you |
# |
Apr 25th 2017, 20:33 |
jeremyharris |
dan223 perhaps matching is what you’re after? https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#filtering-by-associated-data-via-matching-and-joins |
# |
Apr 25th 2017, 20:33 |
losted |
(yes it's cake 2) |
# |
Apr 25th 2017, 20:33 |
losted |
Ok thanks I'll have a look at it |
# |
Apr 25th 2017, 20:32 |
jeremyharris |
(I’m guessing it’s cake 2 from the looks of it) |
# |
Apr 25th 2017, 20:32 |
jeremyharris |
also, you can add all associations and just retrieve them with contain |
# |
Apr 25th 2017, 20:32 |
jeremyharris |
losted that’s probably not the best way to do it, instead look at this: https://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#creating-and-destroying-associations-on-the-fly |
# |
Apr 25th 2017, 20:30 |
dan223 |
I havea a simple application that manages instructors, courses and students. I am trying to rerieve courses an instructor can teach, but am running into a problem. I’ve pasted my find() function here: https://pastebin.com/BT6qLHch - any thoughts? I want to only include courses where there is an entry in InstructorCourses for that instructor and course id. Should I update my find() to retrieve data from InstructorCourses instead of Courses? |