Re: Multiple model types specialization/generalization
Hi Allan, how are you? I would like to know if you have solved your issue because it is the same I have! :) Best regards, Paulo Terra Em quarta-feira, 19 de junho de 2013 11:55:25 UTC-3, Allan Diego escreveu: Hello, How can I implement multiple types of models? example: User (common attributes) (used in the ACL for authentication) User_type_A (specific profile atributes) User_type_B (specific profile atributes) User_type_A should be treated as (User data + specific data) I tried to use User hasOne User_type_A User hasOne User_type_B there are problems: to add a new User_type_A I can not use its own Controller to save User (parent commom data) specializations also relate to others specific model types, and this way cant retrive the parent model data. to do this work i would have to relate to the parent model because then I would have data from 2 models (because hasOne) how can implemnetar this? for cake use (User+User_type_A) as one entity user_A or (Project+Project_type_A) as Project_A https://imageshack.com/a/img407/9510/1r7.png -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Multiple Model Validation
From the controller, you can access $this-validationErrors to view validation errors from multiple models. Though from your example, if you were saving an Order, wouldn't you want to look at $this-Order-validationErrors to see all the errors associated with that save? Regards Reuben Helms On Tuesday, 17 December 2013 02:59:59 UTC+10, advantage+ wrote: When doing something like this: if($this-Order-saveAssociated($this-request-data, array('validate' = 'first'))){ good stuff….. } else { echo 'hello'; debug($this-User-validationErrors); die; } How do I get the list of validation errors? I could not seem to find the answer anywhere. Thanks, Dave -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Multiple model
Hi, I just want agent's username and password inside users table to make sure agents can login. Anyway, i try it first. Thanks. nOLL. On Fri, Aug 19, 2011 at 12:05 PM, Zaky Katalan-Ezra procsh...@gmail.comwrote: Every one how need to login to the application is a user, there for need to be saved in the users table. If you save additional attribute about a specific user it should be in a different table. When you want admins you call select * from users where is_admin = 1; And when you want agents you call select * from users where role = 'agent' and join it with the agents table. What is the problem with mixing users in the same table? On Fri, Aug 19, 2011 at 3:59 AM, Mohd Hasnol hasnolm...@gmail.com wrote: Hi zaky, Thanks for the response. actually i dont face a problem with authentication.The problem is when the admin fill in agents details including username and password, where should it be save? is it in agent table or user table(for admin). Since when login, it will recall username and password inside user's table and not agent's table. As i mention before, i plan not to mix admin details and agent details. I already insert user_id inside agent table but still does'nt work. I already create for user and group and it work. Thanks. nOLL On Thu, Aug 18, 2011 at 6:00 PM, Zaky Katalan-Ezra procsh...@gmail.comwrote: Add a role column to the user info for role based access. I suggest using cakedc users plugin. When creating a new user you can specify a role. I use this code in /cotroller/users/login if ($this-Auth-user()) { if($this-Auth-user('is_admin') == 1) { $this-Auth-redirect('/admin/users/users/dashboard'); } else if ($this-Auth-user('role') == 'agent') { $this-Auth-redirect('/agent/users/users/dashboard'); }else { $this-Auth-redirect('/users/users/dashboard'); } } On Thu, Aug 18, 2011 at 12:14 PM, Mohd Hasnol hasnolm...@gmail.comwrote: Hi zaky, i already create agent table with user_id reference. But, i still cannot login as agent, since my login function will recall username and password in users table. There is no agent's info in the users table. Correct me if i got wrong concept. Thanks. nOLL. On Thu, Aug 18, 2011 at 10:45 AM, Zaky Katalan-Ezra procsh...@gmail.com wrote: Use users plugin. Create an agent table with the additional attribute and user_id to reference the user. Make /users/register visible to admin only. After successful new user registration if the user role is agent, redirect to /admin/agent/add. If you choose to implement role based access you can check the user role in login function and redirect the user with the right prefix. On Thu, Aug 18, 2011 at 4:22 AM, Mohd Hasnol hasnolm...@gmail.comwrote: Thanks.But how the agent would like to login since admin and agents use same login page. i use users table for login function. how i can link agent table to the login function? for my case,at first, admin will decide agents username and password. Then,admin will give it to the agents and they could change their password. Thanks. On Wed, Aug 17, 2011 at 5:21 PM, WebbedIT p...@webbedit.co.ukwrote: ACL has little to do with this as your simply talking about which model to use when creating an Agent, which has more field than a standard User. There is no right answer and you have a choice of using either /users/ agentAdd(agentEdit) or /agents/add(edit). I personally prefer to keep my add and edit actions within their respective controllers so would use the Agent model and include the required User fields in the form. As long as you use $this-Agent- saveAll(); cake will deal with associating the two records for you. HTH, Paul. On Aug 16, 5:28 am, Mohd Hasnol hasnolm...@gmail.com wrote: FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To
Re: Multiple model
I have not used ACL yet, but no matter what type/level of user is logging in they should all use the same login form as all they're providing is there username and password). Auth or un your case ACL then works out what type(s) of user they are and gives them access to the actions applicable to them. HTH, Paul. On Aug 18, 3:45 am, Zaky Katalan-Ezra procsh...@gmail.com wrote: Use users plugin. Create an agent table with the additional attribute and user_id to reference the user. Make /users/register visible to admin only. After successful new user registration if the user role is agent, redirect to /admin/agent/add. If you choose to implement role based access you can check the user role in login function and redirect the user with the right prefix. On Thu, Aug 18, 2011 at 4:22 AM, Mohd Hasnol hasnolm...@gmail.com wrote: Thanks.But how the agent would like to login since admin and agents use same login page. i use users table for login function. how i can link agent table to the login function? for my case,at first, admin will decide agents username and password. Then,admin will give it to the agents and they could change their password. Thanks. On Wed, Aug 17, 2011 at 5:21 PM, WebbedIT p...@webbedit.co.uk wrote: ACL has little to do with this as your simply talking about which model to use when creating an Agent, which has more field than a standard User. There is no right answer and you have a choice of using either /users/ agentAdd(agentEdit) or /agents/add(edit). I personally prefer to keep my add and edit actions within their respective controllers so would use the Agent model and include the required User fields in the form. As long as you use $this-Agent- saveAll(); cake will deal with associating the two records for you. HTH, Paul. On Aug 16, 5:28 am, Mohd Hasnol hasnolm...@gmail.com wrote: FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Multiple model
Hi zaky, i already create agent table with user_id reference. But, i still cannot login as agent, since my login function will recall username and password in users table. There is no agent's info in the users table. Correct me if i got wrong concept. Thanks. nOLL. On Thu, Aug 18, 2011 at 10:45 AM, Zaky Katalan-Ezra procsh...@gmail.comwrote: Use users plugin. Create an agent table with the additional attribute and user_id to reference the user. Make /users/register visible to admin only. After successful new user registration if the user role is agent, redirect to /admin/agent/add. If you choose to implement role based access you can check the user role in login function and redirect the user with the right prefix. On Thu, Aug 18, 2011 at 4:22 AM, Mohd Hasnol hasnolm...@gmail.com wrote: Thanks.But how the agent would like to login since admin and agents use same login page. i use users table for login function. how i can link agent table to the login function? for my case,at first, admin will decide agents username and password. Then,admin will give it to the agents and they could change their password. Thanks. On Wed, Aug 17, 2011 at 5:21 PM, WebbedIT p...@webbedit.co.uk wrote: ACL has little to do with this as your simply talking about which model to use when creating an Agent, which has more field than a standard User. There is no right answer and you have a choice of using either /users/ agentAdd(agentEdit) or /agents/add(edit). I personally prefer to keep my add and edit actions within their respective controllers so would use the Agent model and include the required User fields in the form. As long as you use $this-Agent- saveAll(); cake will deal with associating the two records for you. HTH, Paul. On Aug 16, 5:28 am, Mohd Hasnol hasnolm...@gmail.com wrote: FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Multiple model
Add a role column to the user info for role based access. I suggest using cakedc users plugin. When creating a new user you can specify a role. I use this code in /cotroller/users/login if ($this-Auth-user()) { if($this-Auth-user('is_admin') == 1) { $this-Auth-redirect('/admin/users/users/dashboard'); } else if ($this-Auth-user('role') == 'agent') { $this-Auth-redirect('/agent/users/users/dashboard'); }else { $this-Auth-redirect('/users/users/dashboard'); } } On Thu, Aug 18, 2011 at 12:14 PM, Mohd Hasnol hasnolm...@gmail.com wrote: Hi zaky, i already create agent table with user_id reference. But, i still cannot login as agent, since my login function will recall username and password in users table. There is no agent's info in the users table. Correct me if i got wrong concept. Thanks. nOLL. On Thu, Aug 18, 2011 at 10:45 AM, Zaky Katalan-Ezra procsh...@gmail.comwrote: Use users plugin. Create an agent table with the additional attribute and user_id to reference the user. Make /users/register visible to admin only. After successful new user registration if the user role is agent, redirect to /admin/agent/add. If you choose to implement role based access you can check the user role in login function and redirect the user with the right prefix. On Thu, Aug 18, 2011 at 4:22 AM, Mohd Hasnol hasnolm...@gmail.comwrote: Thanks.But how the agent would like to login since admin and agents use same login page. i use users table for login function. how i can link agent table to the login function? for my case,at first, admin will decide agents username and password. Then,admin will give it to the agents and they could change their password. Thanks. On Wed, Aug 17, 2011 at 5:21 PM, WebbedIT p...@webbedit.co.uk wrote: ACL has little to do with this as your simply talking about which model to use when creating an Agent, which has more field than a standard User. There is no right answer and you have a choice of using either /users/ agentAdd(agentEdit) or /agents/add(edit). I personally prefer to keep my add and edit actions within their respective controllers so would use the Agent model and include the required User fields in the form. As long as you use $this-Agent- saveAll(); cake will deal with associating the two records for you. HTH, Paul. On Aug 16, 5:28 am, Mohd Hasnol hasnolm...@gmail.com wrote: FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials
Re: Multiple model
Hi zaky, Thanks for the response. actually i dont face a problem with authentication.The problem is when the admin fill in agents details including username and password, where should it be save? is it in agent table or user table(for admin). Since when login, it will recall username and password inside user's table and not agent's table. As i mention before, i plan not to mix admin details and agent details. I already insert user_id inside agent table but still does'nt work. I already create for user and group and it work. Thanks. nOLL On Thu, Aug 18, 2011 at 6:00 PM, Zaky Katalan-Ezra procsh...@gmail.comwrote: Add a role column to the user info for role based access. I suggest using cakedc users plugin. When creating a new user you can specify a role. I use this code in /cotroller/users/login if ($this-Auth-user()) { if($this-Auth-user('is_admin') == 1) { $this-Auth-redirect('/admin/users/users/dashboard'); } else if ($this-Auth-user('role') == 'agent') { $this-Auth-redirect('/agent/users/users/dashboard'); }else { $this-Auth-redirect('/users/users/dashboard'); } } On Thu, Aug 18, 2011 at 12:14 PM, Mohd Hasnol hasnolm...@gmail.comwrote: Hi zaky, i already create agent table with user_id reference. But, i still cannot login as agent, since my login function will recall username and password in users table. There is no agent's info in the users table. Correct me if i got wrong concept. Thanks. nOLL. On Thu, Aug 18, 2011 at 10:45 AM, Zaky Katalan-Ezra procsh...@gmail.comwrote: Use users plugin. Create an agent table with the additional attribute and user_id to reference the user. Make /users/register visible to admin only. After successful new user registration if the user role is agent, redirect to /admin/agent/add. If you choose to implement role based access you can check the user role in login function and redirect the user with the right prefix. On Thu, Aug 18, 2011 at 4:22 AM, Mohd Hasnol hasnolm...@gmail.comwrote: Thanks.But how the agent would like to login since admin and agents use same login page. i use users table for login function. how i can link agent table to the login function? for my case,at first, admin will decide agents username and password. Then,admin will give it to the agents and they could change their password. Thanks. On Wed, Aug 17, 2011 at 5:21 PM, WebbedIT p...@webbedit.co.uk wrote: ACL has little to do with this as your simply talking about which model to use when creating an Agent, which has more field than a standard User. There is no right answer and you have a choice of using either /users/ agentAdd(agentEdit) or /agents/add(edit). I personally prefer to keep my add and edit actions within their respective controllers so would use the Agent model and include the required User fields in the form. As long as you use $this-Agent- saveAll(); cake will deal with associating the two records for you. HTH, Paul. On Aug 16, 5:28 am, Mohd Hasnol hasnolm...@gmail.com wrote: FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe
Re: Multiple model
Every one how need to login to the application is a user, there for need to be saved in the users table. If you save additional attribute about a specific user it should be in a different table. When you want admins you call select * from users where is_admin = 1; And when you want agents you call select * from users where role = 'agent' and join it with the agents table. What is the problem with mixing users in the same table? On Fri, Aug 19, 2011 at 3:59 AM, Mohd Hasnol hasnolm...@gmail.com wrote: Hi zaky, Thanks for the response. actually i dont face a problem with authentication.The problem is when the admin fill in agents details including username and password, where should it be save? is it in agent table or user table(for admin). Since when login, it will recall username and password inside user's table and not agent's table. As i mention before, i plan not to mix admin details and agent details. I already insert user_id inside agent table but still does'nt work. I already create for user and group and it work. Thanks. nOLL On Thu, Aug 18, 2011 at 6:00 PM, Zaky Katalan-Ezra procsh...@gmail.comwrote: Add a role column to the user info for role based access. I suggest using cakedc users plugin. When creating a new user you can specify a role. I use this code in /cotroller/users/login if ($this-Auth-user()) { if($this-Auth-user('is_admin') == 1) { $this-Auth-redirect('/admin/users/users/dashboard'); } else if ($this-Auth-user('role') == 'agent') { $this-Auth-redirect('/agent/users/users/dashboard'); }else { $this-Auth-redirect('/users/users/dashboard'); } } On Thu, Aug 18, 2011 at 12:14 PM, Mohd Hasnol hasnolm...@gmail.comwrote: Hi zaky, i already create agent table with user_id reference. But, i still cannot login as agent, since my login function will recall username and password in users table. There is no agent's info in the users table. Correct me if i got wrong concept. Thanks. nOLL. On Thu, Aug 18, 2011 at 10:45 AM, Zaky Katalan-Ezra procsh...@gmail.com wrote: Use users plugin. Create an agent table with the additional attribute and user_id to reference the user. Make /users/register visible to admin only. After successful new user registration if the user role is agent, redirect to /admin/agent/add. If you choose to implement role based access you can check the user role in login function and redirect the user with the right prefix. On Thu, Aug 18, 2011 at 4:22 AM, Mohd Hasnol hasnolm...@gmail.comwrote: Thanks.But how the agent would like to login since admin and agents use same login page. i use users table for login function. how i can link agent table to the login function? for my case,at first, admin will decide agents username and password. Then,admin will give it to the agents and they could change their password. Thanks. On Wed, Aug 17, 2011 at 5:21 PM, WebbedIT p...@webbedit.co.uk wrote: ACL has little to do with this as your simply talking about which model to use when creating an Agent, which has more field than a standard User. There is no right answer and you have a choice of using either /users/ agentAdd(agentEdit) or /agents/add(edit). I personally prefer to keep my add and edit actions within their respective controllers so would use the Agent model and include the required User fields in the form. As long as you use $this-Agent- saveAll(); cake will deal with associating the two records for you. HTH, Paul. On Aug 16, 5:28 am, Mohd Hasnol hasnolm...@gmail.com wrote: FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials
Re: Multiple model
ACL has little to do with this as your simply talking about which model to use when creating an Agent, which has more field than a standard User. There is no right answer and you have a choice of using either /users/ agentAdd(agentEdit) or /agents/add(edit). I personally prefer to keep my add and edit actions within their respective controllers so would use the Agent model and include the required User fields in the form. As long as you use $this-Agent- saveAll(); cake will deal with associating the two records for you. HTH, Paul. On Aug 16, 5:28 am, Mohd Hasnol hasnolm...@gmail.com wrote: FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Multiple model
Thanks.But how the agent would like to login since admin and agents use same login page. i use users table for login function. how i can link agent table to the login function? for my case,at first, admin will decide agents username and password. Then,admin will give it to the agents and they could change their password. Thanks. On Wed, Aug 17, 2011 at 5:21 PM, WebbedIT p...@webbedit.co.uk wrote: ACL has little to do with this as your simply talking about which model to use when creating an Agent, which has more field than a standard User. There is no right answer and you have a choice of using either /users/ agentAdd(agentEdit) or /agents/add(edit). I personally prefer to keep my add and edit actions within their respective controllers so would use the Agent model and include the required User fields in the form. As long as you use $this-Agent- saveAll(); cake will deal with associating the two records for you. HTH, Paul. On Aug 16, 5:28 am, Mohd Hasnol hasnolm...@gmail.com wrote: FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Multiple model
Use users plugin. Create an agent table with the additional attribute and user_id to reference the user. Make /users/register visible to admin only. After successful new user registration if the user role is agent, redirect to /admin/agent/add. If you choose to implement role based access you can check the user role in login function and redirect the user with the right prefix. On Thu, Aug 18, 2011 at 4:22 AM, Mohd Hasnol hasnolm...@gmail.com wrote: Thanks.But how the agent would like to login since admin and agents use same login page. i use users table for login function. how i can link agent table to the login function? for my case,at first, admin will decide agents username and password. Then,admin will give it to the agents and they could change their password. Thanks. On Wed, Aug 17, 2011 at 5:21 PM, WebbedIT p...@webbedit.co.uk wrote: ACL has little to do with this as your simply talking about which model to use when creating an Agent, which has more field than a standard User. There is no right answer and you have a choice of using either /users/ agentAdd(agentEdit) or /agents/add(edit). I personally prefer to keep my add and edit actions within their respective controllers so would use the Agent model and include the required User fields in the form. As long as you use $this-Agent- saveAll(); cake will deal with associating the two records for you. HTH, Paul. On Aug 16, 5:28 am, Mohd Hasnol hasnolm...@gmail.com wrote: FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Multiple model
FYI, Im using ACL for this case. On Tue, Aug 16, 2011 at 12:26 PM, nOLL hasnolm...@gmail.com wrote: Hi, Let say, I'm admin and i would like to add agents but i would like to use different model (not users model). For example, agents model. the reason i use different model because there is other attributes i would like to fill in rather than username and password in users model. What is the best solution for this? Thanks. nOLL -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Multiple Model Pagination
Containable could create multiple queries. This is the solution I went for: http://github.com/ionas/sna/blob/master/www/app/controllers/profiles_controller.php#L112 This could be another solution (not tested yet): http://mark-story.com/posts/view/using-bindmodel-to-get-to-deep-relations (internally pagination uses find() as well) Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Multiple Model Pagination
Here's a new tutorial that's a bit more relevant http://foldifoldi.com/news/?p=466 On Dec 25, 9:15 am, foldiman vi...@vinceallen.com wrote: Andrew, It sounds like you want to use a join in yourpaginationquery. If you have set up your model relationships, the joins may happen automagically. However, you can force the join using the 'joins' parameter in thepaginationquery. For example: $joins1 = array( 'table' = 'bug_relations', 'alias' = 'BugRel', 'type' = 'inner', 'foreignKey' = false, 'conditions' = array( 'BugsGarden.bug_relation_id = BugRel.id', 'BugRel.name LIKE' = '%' . 'beetle' . '%' ) $this-paginate= array( 'BugsGarden' = array( 'limit' = 20, 'order' = array('BugsGarden.created' = 'asc'), 'contain' = array( 'Garden', 'BugRelation' ), 'joins' = array($joins1) ) ) If you wanted to see what Bugs were found in which Garden...specifically which bugs have the string 'beetle' in their name, you could paginate a relation table that carries which bugs are in which garden using ids as foreign keys. You can then get the name from another tablein this example a table called 'bug_relations' that carries info about the various bugs. The join to get the full names or other info is forced in the 'joins' param of thepagination query. Remember to include the table name in your sort keys. An example of cross database queries is also here. http://foldifoldi.com/news/?p=436 I hope this helps, Vince On Dec 24, 12:32 pm, Andrew and...@websitesthatdostuff.com wrote: Greetings, all, I know other people have worked on this before, but I haven't been able to find a solution so far. So, the long and short of it is that I've got multiple models that I want to mix into one view sorted by the date created. I've got a 'created' datetime field in the database already. I understand how to paginate each of the individual database calls and merging that info together, but that doesn't work with the core paginationstuff as I understand it. Do you have any suggestions for developing this? Also, I'd like to keep the number of database calls down, so any suggestions along those lines would be great. Thanks! ~Andrew Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Multiple Model Pagination
I would create an SQL statement using UNION to combine all the data from multiple models and ordered by the same ORDER BY. But this means probably that you have to use a custom query and I don't know if that can be paginated! Example: (SELECT a.id AS Result.id, a.name AS Result.name, a.created AS Result.created FROM table_a AS a WHERE xxx = yyy) UNION (SELECT b.id AS Result.id, b.name AS Result.name, b.created AS Result.created FROM table_b AS b WHERE xxx = yyy) UNION (SELECT c.id AS Result.id, c.name AS Result.name, c.created AS Result.created FROM table_c AS c WHERE xxx = yyy) ORDER BY Result.created I hope you get the idea :) Enjoy, John On Dec 24, 7:32 pm, Andrew and...@websitesthatdostuff.com wrote: Greetings, all, I know other people have worked on this before, but I haven't been able to find a solution so far. So, the long and short of it is that I've got multiple models that I want to mix into one view sorted by the date created. I've got a 'created' datetime field in the database already. I understand how to paginate each of the individual database calls and merging that info together, but that doesn't work with the core pagination stuff as I understand it. Do you have any suggestions for developing this? Also, I'd like to keep the number of database calls down, so any suggestions along those lines would be great. Thanks! ~Andrew Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Multiple Model Pagination
Andrew, It sounds like you want to use a join in your pagination query. If you have set up your model relationships, the joins may happen automagically. However, you can force the join using the 'joins' parameter in the pagination query. For example: $joins1 = array( 'table' = 'bug_relations', 'alias' = 'BugRel', 'type' = 'inner', 'foreignKey' = false, 'conditions' = array( 'BugsGarden.bug_relation_id = BugRel.id', 'BugRel.name LIKE' = '%' . 'beetle' . '%' ) $this-paginate= array( 'BugsGarden' = array( 'limit' = 20, 'order' = array('BugsGarden.created' = 'asc'), 'contain' = array( 'Garden', 'BugRelation' ), 'joins' = array($joins1) ) ) If you wanted to see what Bugs were found in which Garden...specifically which bugs have the string 'beetle' in their name, you could paginate a relation table that carries which bugs are in which garden using ids as foreign keys. You can then get the name from another tablein this example a table called 'bug_relations' that carries info about the various bugs. The join to get the full names or other info is forced in the 'joins' param of the pagination query. Remember to include the table name in your sort keys. An example of cross database queries is also here. http://foldifoldi.com/news/?p=436 I hope this helps, Vince On Dec 24, 12:32 pm, Andrew and...@websitesthatdostuff.com wrote: Greetings, all, I know other people have worked on this before, but I haven't been able to find a solution so far. So, the long and short of it is that I've got multiple models that I want to mix into one view sorted by the date created. I've got a 'created' datetime field in the database already. I understand how to paginate each of the individual database calls and merging that info together, but that doesn't work with the core pagination stuff as I understand it. Do you have any suggestions for developing this? Also, I'd like to keep the number of database calls down, so any suggestions along those lines would be great. Thanks! ~Andrew Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: multiple model
That is fine that i need to let Paginator know which one you want. But i made grid layout with help of two model and when user click any field title it should be in sorted in ASC or DESC and also that those field is coming from different model. On Sep 16, 2:31 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: To paginate anything but the first defined model you need to let Paginator know which one you want. Check out the Pagination chapter in the book.http://book.cakephp.org/view/165/Controller-Setup On Sep 15, 3:03 pm,nayan[EMAIL PROTECTED] wrote: i have wrote the following code to use mulitple model class AutoLinkExchangesController extends AppController { var $name = 'AutoLinkExchanges'; var $uses=array('AutoLinkExchange','AutoHyperLink'); function admin_autohyperlink_index(){ if(!empty($this-data)) { $criteria=NULL; list($order,$limit,$page) = $this-Pagination-init($criteria); $data = $this-AutoHyperLink-findAll($criteria, NULL, $order, $limit, $page); } it shows me the queryu with ORDER BY `AutoLinkExchange`.`id` but i am using AutoHyperLink model and one more thing when i change the position of model in uses like var $uses=array('AutoHyperLink','AutoLinkExchange'); then it does not show me any error and both model do not have any relation. Plz suggest me the solution.. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---