Saving unique data in hasMany through model

2014-09-02 Thread Jaz
Here's the associations that I have set up:

Partner hasMany PartnerInvolvement
Product hasMany PartnerInvolvement
PartnerInvolvementType hasMany PartnerInvolvement
PartnerInvolvement belongsTo Partner, Product, PartnerInvolvementType

The $hasMany relationship is defined the same way in all 3 of the Partner, 
Product, PartnerInvolvementType models:
class Product {

public $hasMany = array(

'PartnerInvolvement' => array(
'className' => 'PartnerInvolvement',
'foreignKey' => 'product_id',
'dependent' => true,
'unique' => 'keepExisting'
)

); 

}


When adding/editing a new Product, I want to be able to choose which 
Partners are involved with that Product, which PartnerInvolvementType it 
is, and create new PartnerInvolvement relationships from that data.

Here is the data that I am trying to save:

Array
(
[Product] => Array
(
[id] => 2981
[name] => Laurie Amerson Rental itr1229
[product_type_id] => 12
[default_price] => 0.00
)

[PartnerInvolvement] => Array
(
[0] => Array
(
[partner_id] => 1
[partner_involvement_type_id] => 1
)

[1] => Array
(
[partner_id] => 2
[partner_involvement_type_id] => 1
)

)

)
My app is creating a new PartnerInvolvement entry any time I try to save this 
data.  I am trying to restrain it so that a unique combination of product_id, 
partner_id, partner_involvement_type_id is only saved once.  Any suggestions?  
Should I go back to using a HABTM instead of a hasMany through relationship?

-- 
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: CakePHP 3.0 beta 1: Please help to use Html helper in function on view

2014-09-02 Thread José Lorenzo
Where did you put that generateLink() function?

Helpers can only be used in the templates and from other helpers. What you 
are trying to do is not possible. You can create other helpers that can 
call the Html helper internally

On Tuesday, September 2, 2014 1:57:30 PM UTC+2, Nguyễn Anh Tuấn wrote:
>
> Dear all.
> This so stupid but please help me.
> In my cell: *app/src/View/Cell/MyCell.php*
> i'm use public $helpers = ['Html'];
> In my cell view: *app/src/Template/Cell/MyCell/display.ctp*
>
>  $this->Html->link('name', ['controller' => 'mycontroller', 'action' => 
> 'myaction', 'param']); // This one work correctly
> function generateLink($name) {
>return $this->Html->link($name, ['controller' => 'mycontroller', 
> 'action' => 'myaction', 'param']); // This one cannot work then   
>  output error: Using $this when not in object context
> }
>
> echo generateLink('MyLinkName');
> ?>
>
> *Please guide me how to use $this inside view function.*
> *Thanks.*
>

-- 
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: Paginate Sort on columns from related tables

2014-09-02 Thread José Lorenzo
you will need to use something like http://github.com/lorenzo/linkable to 
make that work

You add the behavior to the models: $actsAs = ['Linkable.Linkable'];

Then in your Paginator options you can add:

$this->Paginator->settings['link'] = ['Patient' => ['CareGiver']];

This will probably help you getting the models in the same query so you can 
sort by them.

On Thursday, August 28, 2014 3:54:01 PM UTC+2, John Sposato wrote:
>
> We are having some issues getting this to work, is it possible?
>
> For example,
>
> We have a Patient model with a HABTM relationship to CareGiver.  And a 
> PatientCase model that belongs to Patient with the hasMany to it from 
> Patient.  Both HABTM relationships are setup and are correct.  
>
> On the patient_cases index, we are trying to sort on some CareGiver 
> columns, but it's not working.  It seems to sort, but not by those columns. 
>  Is going from PatientCase->Patient->CareGiver too far for Paginate to sort 
> columns?
>

-- 
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: load model from another module

2014-09-02 Thread Nguyễn Anh Tuấn
Did you try this one?
$this->loadModel('Users');

On Monday, August 25, 2014 10:39:59 AM UTC+7, Hasrul Mikael wrote:
>
> Hai,
> I'm new in CakePHP. Currently I got a problem in my task. 
> I had assigned to create a Plugin name UserManagement and Login in 
> app/Plugin/
> The Plugin UserManagement already has completed. But now I having a 
> problem in Plugin Login. Actually I need to use User Model from Plugin 
> UserManagement in Plugin Login. However, I don't know how to write a 
> scripts and what steps first I should taken? 
>
> I try before, create LoginsController in Controller. But It display an 
> error mentioned that I need to create Model first. Infact that, I actually 
> plan to use Model from UserManagement.
>
> Please assists. Thank you.
> Sorry..my English is bad. TT_TT
>

-- 
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.


CakePHP 3.0 beta 1: Please help to use Html helper in function on view

2014-09-02 Thread Nguyễn Anh Tuấn
Dear all.
This so stupid but please help me.
In my cell: *app/src/View/Cell/MyCell.php*
i'm use public $helpers = ['Html'];
In my cell view: *app/src/Template/Cell/MyCell/display.ctp*

Html->link('name', ['controller' => 'mycontroller', 'action' => 
'myaction', 'param']); // This one work correctly
function generateLink($name) {
   return $this->Html->link($name, ['controller' => 'mycontroller', 'action' 
=> 'myaction', 'param']); // This one cannot work thenoutput error: 
Using $this when not in object context
}

echo generateLink('MyLinkName');
?>

*Please guide me how to use $this inside view function.*
*Thanks.*

-- 
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: Why CakePHP ?

2014-09-02 Thread Stephen S
Additional to what John said, in my experience hosting for Java
applications is usually more expensive than PHP applications, though it has
been a couple of years so this may no longer be the case...


On 2 September 2014 12:51, John Sposato  wrote:

> When you say JAVA, I assume you mean a JAVA framework (Spring, Grails,
> etc.) since I don't believe you can write a web application is straight
> JAVA (I may be wrong). CakePHP is a framework, which follows the
> Model/View/Controller pattern.  The developers of the framework have
> abstracted away a lot of the gotchas that usually come with writing an
> application in straight PHP.
>
> As for PHP framework vs. JAVA framework, it really depends on the use case
> for your application.  Where I work, we have over 20 CakePHP applications,
> and we haven't had anything we've tried that we couldn't accomplish.
>
> It probably also depends on which language you are more comfortable with.
>
>
> On Tuesday, September 2, 2014 1:47:59 AM UTC-4, prakhil samar wrote:
>>
>> Hi All,
>>
>> Hope you all are doing well
>>
>> I have a question, or i would say a confusion.
>>
>> I need to built a website approx 80 web pages. This will be a CMS site.
>>
>> I have a confusion that should i built that in JAVA or CakePHP.
>>
>> Can someone please educate me exact differences between the both, i mean
>> advantages of CakePHP over JAVA or vice versa ?
>>
>> Thanks
>>
>  --
> 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.
>



-- 
Kind Regards
 Stephen Speakman

-- 
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: Paginate Sort on columns from related tables

2014-09-02 Thread John Sposato
Any ideas?

On Thursday, August 28, 2014 9:54:01 AM UTC-4, John Sposato wrote:
>
> We are having some issues getting this to work, is it possible?
>
> For example,
>
> We have a Patient model with a HABTM relationship to CareGiver.  And a 
> PatientCase model that belongs to Patient with the hasMany to it from 
> Patient.  Both HABTM relationships are setup and are correct.  
>
> On the patient_cases index, we are trying to sort on some CareGiver 
> columns, but it's not working.  It seems to sort, but not by those columns. 
>  Is going from PatientCase->Patient->CareGiver too far for Paginate to sort 
> columns?
>

-- 
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: Why CakePHP ?

2014-09-02 Thread John Sposato
When you say JAVA, I assume you mean a JAVA framework (Spring, Grails, 
etc.) since I don't believe you can write a web application is straight 
JAVA (I may be wrong). CakePHP is a framework, which follows the 
Model/View/Controller pattern.  The developers of the framework have 
abstracted away a lot of the gotchas that usually come with writing an 
application in straight PHP.

As for PHP framework vs. JAVA framework, it really depends on the use case 
for your application.  Where I work, we have over 20 CakePHP applications, 
and we haven't had anything we've tried that we couldn't accomplish.

It probably also depends on which language you are more comfortable with.

On Tuesday, September 2, 2014 1:47:59 AM UTC-4, prakhil samar wrote:
>
> Hi All,
>
> Hope you all are doing well
>
> I have a question, or i would say a confusion.
>
> I need to built a website approx 80 web pages. This will be a CMS site. 
>
> I have a confusion that should i built that in JAVA or CakePHP.
>
> Can someone please educate me exact differences between the both, i mean 
> advantages of CakePHP over JAVA or vice versa ?
>
> Thanks
>

-- 
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.


Why CakePHP ?

2014-09-02 Thread prakhil samar
Hi All,

Hope you all are doing well

I have a question, or i would say a confusion.

I need to built a website approx 80 web pages. This will be a CMS site. 

I have a confusion that should i built that in JAVA or CakePHP.

Can someone please educate me exact differences between the both, i mean 
advantages of CakePHP over JAVA or vice versa ?

Thanks

-- 
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.