# |
Apr 26th 2017, 08:59 |
Neon1024 |
It is |
# |
Apr 26th 2017, 08:58 |
birdy247 |
It seems "wrong" that the class will be retrieving entities |
# |
Apr 26th 2017, 08:58 |
birdy247 |
I am making a new class in my Lib folder as I want to share the logic between a shell and model |
# |
Apr 26th 2017, 08:23 |
johnwayne |
I want to write manual address in case that id = 3 |
# |
Apr 26th 2017, 08:23 |
johnwayne |
I am using now protected function _getFullAddress() { return $this->_properties['address'] . ' ' . $this->_properties['building_number'] . ', ' . $this->_properties['postal'] . ' ' . $this->_properties['city']; } |
# |
Apr 26th 2017, 08:23 |
johnwayne |
Is there way to define virtual field with conditions. If id == 3 than create own name? |
# |
Apr 26th 2017, 08:22 |
steinkel |
@joshuaso91 you have specific documentation here https://github.com/CakeDC/users/blob/master/Docs/Documentation/Extending-the-Plugin.md#extending-the-model-tableentity> and a working example here <https://ide.c9.io/steinkel/users-example-custom-table you could clone/review |
# |
Apr 26th 2017, 08:21 |
chris-andre |
I find using migrations very nice and helpful. |
# |
Apr 26th 2017, 08:21 |
chris-andre |
@joshuaso91 Ofc you don't have to use migrations to set up database. You can use your own sql files or what ever. |
# |
Apr 26th 2017, 08:18 |
joshuaso91 |
@digitalfotografen Hey there Digitalfotografen, I got a question, if i dont want to migrate the users table and just use my own that i already have, can i just skip that step? |
# |
Apr 26th 2017, 08:12 |
inoas |
Nitpick @PR https://github.com/cakephp/cakephp/pull/10583/files#diff-7c230f89390b8e761527d8e592166f4fR395: Can we find one way in the core to concat Exceptions with variables? / Examples: https://3v4l.org/XpvHW / To Curley or To Not Curley: http://stackoverflow.com/a/2596838 |
# |
Apr 26th 2017, 07:44 |
metoyoko |
@ndgAl thank you. god bless |
# |
Apr 26th 2017, 07:42 |
ndgAl |
sorry, I have to go, good luck |
# |
Apr 26th 2017, 07:42 |
ndgAl |
@metoyoko like @chris-andre says, you must `debug($this->request->getData())` to check if your associated data is present and the structure looks conform to what Cake expect to marshal it. Then Debug($article) will inform you if it correctly process the data and if dirty property is true to persist it |
# |
Apr 26th 2017, 07:42 |
birdy247 |
morning |
# |
Apr 26th 2017, 07:41 |
metoyoko |
sometimes she not used plural in table name like cms_ref_status |
# |
Apr 26th 2017, 07:40 |
metoyoko |
@ndgAl but my tables has suffix like cms_articles and field just article_id. db admin already established current db and we argue on that but she insist not to follow cake naming convention :( |
# |
Apr 26th 2017, 07:38 |
chris-andre |
If you're not sure if your associations are setup right, check the docs, eventually, gist your file. |
# |
Apr 26th 2017, 07:37 |
chris-andre |
@metoyoko Have you, like ndgAl said, `debug( $this->request->getData() )` in your controller to ensure associated data is there? |
# |
Apr 26th 2017, 07:35 |
digitalfotografen |
Yes, you should be in the app root folder when using the composer command. Composer is a really powerfull dependency manager / installer. With Cake 3 that is the prefered method to install modules. |
# |
Apr 26th 2017, 07:35 |
ndgAl |
@metoyoko, usually, if you follow Cake naming convention, the less you specify in table class, the less error you could have. i.e. in Articles table only $this->hasMany('Tags') is necessary and in Tags $this->belongsTo('Articles') only |
# |
Apr 26th 2017, 07:33 |
joshuaso91 |
@digitalfotografen like in the root folder of my project* |
# |
Apr 26th 2017, 07:32 |
joshuaso91 |
@digitalfotografen One last question, so if we use "compose" we use the compose command in the bake files we have yea? |
# |
Apr 26th 2017, 07:31 |
metoyoko |
in my model, I used className = 'my table name' and I just used my assigned alias. like this: 'associated' => 'myAlias' |
# |
Apr 26th 2017, 07:30 |
chris-andre |
Morning! |
# |
Apr 26th 2017, 07:30 |
digitalfotografen |
@joshuaso91 You are welcome! |
# |
Apr 26th 2017, 07:29 |
joshuaso91 |
@digitalfotografen No worries~! Thank you so much for recommending this to me. I appreciate your help. If any other questions I'll give a shoutout |
# |
Apr 26th 2017, 07:27 |
ndgAl |
@metoyoko $this->Articles is good, I usually debug($this->request->getData() and debug($article) to see why newEntity() or patchEntoty() is not correctly marshaled but maybe there is a little problem in your table classes definitions |
# |
Apr 26th 2017, 07:26 |
digitalfotografen |
Sorry @joshuaso91 I don't have time to look at Your database. I am just a CakePHP user answering questions in spare time. But what You describe can be done with the CakeDC/Users. I hope Your will bake som really taste apps with cake! |
# |
Apr 26th 2017, 07:24 |
joshuaso91 |
@digitalfotografen that's so that you can have a look at how it is |
# |
Apr 26th 2017, 07:24 |
joshuaso91 |
@digitalfotografen If you want a copy of my database i can send you in a PM |
# |
Apr 26th 2017, 07:23 |
joshuaso91 |
@digitalfotografen my level in CakePHP is still beginner, I only know how to do all the basics that's about it. I'm learning all these stuff from scratch. So yea. I am looking up bits and pieces of what i need to look for as for now I have a Users table that has the field 'Roles' where there have three access level - Super Admin, Admin, Staff. I wanna assign each access Level to different parts of my system i am building for a company. So |
# |
Apr 26th 2017, 07:22 |
metoyoko |
thanks for answer, I dont use TableRegistry::get('Articles'); I used $this->Articles; I already followed the instruction but then its only inserted to article table not to hasmany table related |
# |
Apr 26th 2017, 07:07 |
ndgAl |
@metoyoko normally in the same way as other associations except that you may have to mark your entity as dirty if you update it https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-hasmany-associations |
# |
Apr 26th 2017, 07:06 |
joshuaso91 |
i am reading the migrations now to see how i can migrate my current DB |
# |
Apr 26th 2017, 07:06 |
joshuaso91 |
i build it in phpmyadmin and then use the bin\cake bake all to build the system |
# |
Apr 26th 2017, 07:06 |
joshuaso91 |
i build my database off the databse ERD i drew up |
# |
Apr 26th 2017, 07:02 |
metoyoko |
How to save in cakephp with hasMany |
# |
Apr 26th 2017, 07:02 |
metoyoko |
good day! |
# |
Apr 26th 2017, 06:57 |
slackebot1 |
I am still feeling like a rookie). But a key to get the power from CakePHP is to use plugins. Then to create tables I recommend looking at Migrations. Many modules use that to create the needed tables, and using it for you own tables makes Your app easy to maintain. https://book.cakephp.org/3.0/en/migrations.html |
# |
Apr 26th 2017, 06:57 |
digitalfotografen |
@joshuaso91 In many cases You don't need to extend the plugin. I don't know how complicated Your user tables you need. But if you use Migrations to create the tables you will have it up un running quickly. To store more information about users you can hav another table with user id as foreign key and join. In many cases a key/value storage will do. I don't know Your level, but You wrote that you are new to CakePHP (we all were once |