Friday, July 31, 2015

Re: how to Deploy CakePHP 2.6.6 on godaddy shared windows hosting plan?

Hi

Compartenos el Log para poder tener saber que puede pasar

--
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+unsubscribe@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 - hasMany through association

Try:

$query = $this->Courses->find('all')
                       ->contain(['Students', 'CourseMemberships'])
                       ->where(['Students.id' => $student_id])
                       ->matching('CourseMemberships', function ($q) {
                            return $q->where([ 'CourseMemberships.grade' => 'A']);
                       });

* Recommendation: use $studentId, not $student_id.

On Sun, Jul 26, 2015 at 9:06 PM, Zbigniew Ledwoń <zledwon@gmail.com> wrote:
if I have an association exactly like in the CookBook here:

class StudentsTable extends Table  {      public function initialize(array $config)      {          $this->belongsToMany('Courses', [              'through' => 'CourseMemberships',          ]);      }  }    class CoursesTable extends Table  {      public function initialize(array $config)      {          $this->belongsToMany('Students', [              'through' => 'CourseMemberships',          ]);      }  }    class CoursesMembershipsTable extends Table  {      public function initialize(array $config)      {          $this->belongsTo('Students');          $this->belongsTo('Courses');      }  }
Student BelongsToMany Course  Course BelongsToMany Student
id | student_id | course_id | days_attended | grade
How do I find all Courses that given Student has Grade == "A"?
Would following code work fine?

$query = $this->Courses->find('all')
    ->contain(['Students', 'CourseMemberships'])
    ->where(['Students.id' => $student_id, 'CourseMemberships.grade' => 'A']);


--
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+unsubscribe@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.



--
Atenciosamente,

Rafael F. Queiroz

--
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+unsubscribe@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.

Model "X" is not associated with model "Y" - But works on first level

Hello,

I know this question has been posted some times but my model looks correctly linked.
I'm on the latest cakephp 2.7.1.

Ticket belongsTo User
Ticket belongsTo Event
Event hasMany Ticket
Event belongsTo Venue
Event belongsTo ParentEvent
Event hasMany ChildEvent
Venue hasMany Event
User hasMany Ticket


From Tickets Controller:
$this->Ticket->contain(array(
  "Evenement" => array(
     "Venue",
  )
));

debug($this->Ticket->find('all'));


Model "Evenement" is not associated with model "Venue"
(int) 0 => array(  		'Ticket' => array(  			'id' => '1',  			'user_id' => '1',  			'event_id' => '1',  			'amount' => '2',  			'price' => '30',  			'message' => null,  			'status' => true,  			'created' => null,  			'updated' => '2015-07-29 12:47:51',  			'pricePerTicket' => '15.00'  		),  		'Event' => array(  			'id' => '1',  			'venue_id' => '3',  			'parent_id' => '0',  			'title' => 'Action Bronson',  			'slug' => null,  			'start_datetime' => '2015-09-27 19:00:00',  			'end_datetime' => '2015-07-29 09:11:00',  			'body' => 'L'ancien cuisinier sort son album Mr. Wonderful' chez Vice/Atlantic.',  			'facebook_url' => 'https://www.facebook.com/events/1575996599351',  			'website_url' => '',  			'songkick_ref' => null,  			'status' => '1',  			'promote' => false,  			'created' => '2015-07-29 09:15:32',  			'updated' => '2015-07-29 10:40:05'  		)  	),
Which is wrong. Venue model is properly linked since it works when doing a find from Events controller.



From Events controller.
$this->Evenement->contain(
                        array(
                            "Venue" 
                        )
                );
debug($this->Evenement->find('all'));

(int) 0 => array(  		'Evenement' => array(  			'id' => '1',  			'venue_id' => '3',  			'parent_id' => '0',  			'title' => 'Action Bronson',  			'slug' => null,  			'start_datetime' => '2015-09-27 19:00:00',  			'end_datetime' => '2015-07-29 09:11:00',  			'body' => 'L'ancien cuisinier sort son album Mr. Wonderful' chez Vice/Atlantic.',  			'facebook_url' => 'https://www.facebook.com/events/1575996599351',  			'website_url' => '',  			'songkick_ref' => null,  			'status' => '1',  			'promote' => false,  			'created' => '2015-07-29 09:15:32',  			'updated' => '2015-07-29 10:40:05',  			'displayname' => 'Action Bronson, 2015-09-27 19:00:00'  		),  		'Venue' => array(  			'id' => '3',  			'title' => 'Ancienne Belgique',  			'slug' => 'ancienne-belgique',  			'body' => '',  			'city' => 'Brussels',  			'country' => 'Belgium',  			'facebook_url' => '',  			'website_url' => '',  			'lat' => null,  			'lng' => null,  			'status' => '1',  			'promote' => false,  			'created' => '2015-07-29 08:25:47',  			'updated' => '2015-07-29 10:39:57'  		)  	),


  • AppModel acts as Containable.
  • I tried to change 'event' to 'evenement' in french since event is a mysql reserved word but nothing changed. I got rid of parent/child things with no luck as well.
  • Doing a regular find without 'Contain' and recursive->2 gets a lots of User related models but still nothing under Event.


Thanks a lot of your time.

--
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+unsubscribe@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.

Wednesday, July 29, 2015

logging in with user's email address only with Facebook account

hi I'm making an application which let user login with their Facebook account.
then after i get their profile such as email address, I store the email address to user table.
but I don't know how to log the user in.

here is my code below.

$fbUser = FacebookService::Instance()->getProfile();
$fbUser = json_decode($fbUser);
if(is_null($fbUser->email)){
$this->Flash->error('We cannot retrieve your email address from Facebook');
}
$user = UserService::Instance()->getUserByEmail($fbUser->email);
session_destroy();
if($this->Auth->setUser($user->toArray())){
$this->Flash->success('Login success with facebook');
}else{
$this->Flash->error('login failed with facebook');
}
$this->set(compact('user'));

after initialize these code, I get login failed with Facebook error.

Please let me know Thank you

--
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+unsubscribe@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 1.3 Shell can't find AppModel class

This was solved in Stack Overflow.

--
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+unsubscribe@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 Login form with different database tables

I am trying to create a login form for different types of users like

`Suppliers`, `Distributors`, `Managers`


on the website like

http://azzip.de/distributors/login

And the Distributor's beforeFilter looks like

   
public function beforeFilter() {
   
    parent
::beforeFilter();
   
   
AuthComponent::$sessionKey = 'Auth.Distributor';
   
    $this
->Auth->authenticate = array(
   
'Form' => array(
   
'userModel' => 'Distributor',
   
'fields' => array(
   
'username' => 'email',
   
'password' => 'password'
   
),
   
'scope' => array(
   
'Distributor.active' => 1,
   
)
   
)
   
);
   
    $this
->Auth->allow('login', 'forgotpass', 'register');
   
}


The passwords are hashed. But no chance to login. and unfortunately also can't see the the
`login()`

query to debug. 

--
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+unsubscribe@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.

Unsupported operand type in TestSuite

Hi All,

I am having issues when running phpunit against my application with the following error within cake:

Fatal error: Unsupported operand types in /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/TestSuite/CakeTestCase.php on line 695

I can see some similar issues on stackflow etc that suggest that the issue is the use of += with an array.  However I can't imagine that others wouln't have already ran into this, so I suspect it is something to do with my setup.  Any help to point me in the right direction is appreciated.

I am running Debain 8
PHP: 5.6.9-0+deb8u1
PHPUnit 3.7.38
and Cake 2.4.3

Here is a copy of the full trace:

Fatal error: Unsupported operand types in /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/TestSuite/CakeTestCase.php on line 695

Call Stack:
    0.0001     227408   1. {main}() /var/lib/jenkins/jobs/unittest/workspace/app/Console/cake.php:0
    0.0007     315816   2. ShellDispatcher::run() /var/lib/jenkins/jobs/unittest/workspace/app/Console/cake.php:36
    0.0626    2166776   3. ShellDispatcher->dispatch() /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/Console/ShellDispatcher.php:66
    0.2120    3541872   4. Shell->runCommand() /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/Console/ShellDispatcher.php:207
    0.2221    4404832   5. TestShell->main() /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/Console/Shell.php:434
    0.2222    4406496   6. TestShell->_run() /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/Console/Command/TestShell.php:258
    0.2631    4634800   7. CakeTestSuiteCommand->run() /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/Console/Command/TestShell.php:273
    0.6596   15788368   8. CakeTestRunner->doRun() /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/TestSuite/CakeTestSuiteCommand.php:95
    0.6613   15856232   9. PHPUnit_TextUI_TestRunner->doRun() /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/TestSuite/CakeTestRunner.php:60
    0.6673   16179416  10. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:423
    1.0957   22429624  11. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:703
    5.2642   67485280  12. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:703
    5.2946   67830000  13. CakeTestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:703
    5.2946   67830000  14. PHPUnit_Framework_TestCase->run() /var/lib/jenkins/jobs/unittest/workspace/lib/Cake/TestSuite/CakeTestCase.php:82
    5.2946   67830000  15. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:771
    5.2947   67831008  16. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:643
    5.2952   67866560  17. PHPUnit_Framework_TestCase->runTest() /usr/share/php/PHPUnit/Framework/TestCase.php:835
    5.2952   67867384  18. ReflectionMethod->invokeArgs() /usr/share/php/PHPUnit/Framework/TestCase.php:963
    5.2952   67867592  19. TimeSlotsUtilitiesComponentTest->testGetSlotsForDateTimeSuccess() /usr/share/php/PHPUnit/Framework/TestCase.php:963
    5.2952   67868144  20. CakeTestCase->getMockForModel() /var/lib/jenkins/jobs/unittest/workspace/app/Test/Case/Controller/Component/TimeSlotsUtilitiesComponentTest.php:93

Regards
Callum

--
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+unsubscribe@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.

Tuesday, July 28, 2015

Upload Plugin

Hi,

I`m using https://github.com/josegonzalez/cakephp-upload for upload file.
After save, i'm sending by attachments in CakeEmail.

I have problems to special characters in files names.
Better save without characters specials or sanitize before send ?
Thanks.

--
Atenciosamente,

Rafael F. Queiroz

--
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+unsubscribe@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.

Monday, July 27, 2015

Re: Recording Emails Sent

Hi,

assuming Cakephp 2.x:

$Email = new CakeEmail();
//....... all the additional email settings  ....
$result
= $Email->send();

$result['message']  contains the whole email message (txt, html even with attachments),
1. you can parse this to get txt and html parts.
2. option as you wrote, writing your own Email class extending the CakeEmail where you put these getters:

App::uses('CakeEmail', 'Network/Email');
class myCakeEmail extends CakeEmail {
     
public function getTxtMessage() {
         
return $this->_textMessage;
     
}
     
public function getHtmlMessage() {
         
return $this->_htmlMessage;
     
}
}

then simply get the relevant message like this
$Email = new myCakeEmail();
//....... all the additional email settings  ....
if ($Email->send()) {
    $htmlBody
= $Email->getHtmlMessage();
}

Martin

On Monday, July 27, 2015 at 4:53:19 PM UTC+2, #2Will wrote:
I'm trying to work out a good way to record all the emails the system has sent. I want to record them to DB, with columns for To, Subject and Message. 

I don't think that CakeEmail triggers any events or callbacks I can hook into?
If I write a custom Log, I think I just get back the Whole message as text.  

It seems like the best way is to  write my own myEmail class that extends CakeEmail.

how can I get hold of the HTML message and Text message to be sent from within say the send method?

Will

--
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+unsubscribe@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.

Recording Emails Sent

I'm trying to work out a good way to record all the emails the system has sent. I want to record them to DB, with columns for To, Subject and Message. 

I don't think that CakeEmail triggers any events or callbacks I can hook into?
If I write a custom Log, I think I just get back the Whole message as text.  

It seems like the best way is to  write my own myEmail class that extends CakeEmail.

how can I get hold of the HTML message and Text message to be sent from within say the send method?

Will

--
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+unsubscribe@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 Plugin - Where to put a « global » function for multiple helpers

Thanks! Exactly what I was looking for.

On Monday, July 27, 2015 at 2:29:31 PM UTC+2, Florian Krämer wrote:
Then use a trait.

On Monday, July 27, 2015 at 11:32:54 AM UTC+2, Mikaël Capelle wrote:
I cannot do that without multiple inheritance (which, as far as I know, does not exist in php) because as I stated in my post, all my helpers does not inherit a standard CakePHP helpers, for instance I have:

class MyHTMLHelper extends HTMLHelper { ... }
class MyFormHelper extends FormHelper { ... }
class MyPagiHelper extends PaginatorHelper { ... }

On Monday, July 27, 2015 at 11:28:00 AM UTC+2, Florian Krämer wrote:
Simple OOP?

MySpecialHelper extends MyBaseHelper {...}
MyOtherSpecialHelper extends MyBaseHelper {...}



And MyBaseHelper implementds addClass().

On Friday, July 24, 2015 at 10:23:43 AM UTC+2, Mikaël Capelle wrote:
Hi everyone,

I am writing a CakePHP 3.0 plugins, and I have multiple helpers (inheriting from either HTMLHelper, FormHelper, PaginatorHelper, etc.). In each of these new helpers, I have a function addClass (copy/paste from helper to helper... ).

I don't really like having duplicated code (5 times... ), but I don't know where I should put this function to follow CakePHP 3.0 plugin conventions, knowing that the plugin consists of only helpers?

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+unsubscribe@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 Plugin - Where to put a « global » function for multiple helpers

Then use a trait.

On Monday, July 27, 2015 at 11:32:54 AM UTC+2, Mikaël Capelle wrote:
I cannot do that without multiple inheritance (which, as far as I know, does not exist in php) because as I stated in my post, all my helpers does not inherit a standard CakePHP helpers, for instance I have:

class MyHTMLHelper extends HTMLHelper { ... }
class MyFormHelper extends FormHelper { ... }
class MyPagiHelper extends PaginatorHelper { ... }

On Monday, July 27, 2015 at 11:28:00 AM UTC+2, Florian Krämer wrote:
Simple OOP?

MySpecialHelper extends MyBaseHelper {...}
MyOtherSpecialHelper extends MyBaseHelper {...}



And MyBaseHelper implementds addClass().

On Friday, July 24, 2015 at 10:23:43 AM UTC+2, Mikaël Capelle wrote:
Hi everyone,

I am writing a CakePHP 3.0 plugins, and I have multiple helpers (inheriting from either HTMLHelper, FormHelper, PaginatorHelper, etc.). In each of these new helpers, I have a function addClass (copy/paste from helper to helper... ).

I don't really like having duplicated code (5 times... ), but I don't know where I should put this function to follow CakePHP 3.0 plugin conventions, knowing that the plugin consists of only helpers?

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+unsubscribe@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 Plugin - Where to put a « global » function for multiple helpers

I cannot do that without multiple inheritance (which, as far as I know, does not exist in php) because as I stated in my post, all my helpers does not inherit a standard CakePHP helpers, for instance I have:

class MyHTMLHelper extends HTMLHelper { ... }
class MyFormHelper extends FormHelper { ... }
class MyPagiHelper extends PaginatorHelper { ... }

On Monday, July 27, 2015 at 11:28:00 AM UTC+2, Florian Krämer wrote:
Simple OOP?

MySpecialHelper extends MyBaseHelper {...}
MyOtherSpecialHelper extends MyBaseHelper {...}



And MyBaseHelper implementds addClass().

On Friday, July 24, 2015 at 10:23:43 AM UTC+2, Mikaël Capelle wrote:
Hi everyone,

I am writing a CakePHP 3.0 plugins, and I have multiple helpers (inheriting from either HTMLHelper, FormHelper, PaginatorHelper, etc.). In each of these new helpers, I have a function addClass (copy/paste from helper to helper... ).

I don't really like having duplicated code (5 times... ), but I don't know where I should put this function to follow CakePHP 3.0 plugin conventions, knowing that the plugin consists of only helpers?

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+unsubscribe@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 Plugin - Where to put a « global » function for multiple helpers

Simple OOP?

MySpecialHelper extends MyBaseHelper {...}
MyOtherSpecialHelper extends MyBaseHelper {...}



And MyBaseHelper implementds addClass().

On Friday, July 24, 2015 at 10:23:43 AM UTC+2, Mikaël Capelle wrote:
Hi everyone,

I am writing a CakePHP 3.0 plugins, and I have multiple helpers (inheriting from either HTMLHelper, FormHelper, PaginatorHelper, etc.). In each of these new helpers, I have a function addClass (copy/paste from helper to helper... ).

I don't really like having duplicated code (5 times... ), but I don't know where I should put this function to follow CakePHP 3.0 plugin conventions, knowing that the plugin consists of only helpers?

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+unsubscribe@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.

How to Unique URL like myhost.com/username,myhost.com/pages,myhost.com/groups

Hi Team/Friends,

i am new to cakePHP,

i want implement unique URL like facebook username,pages,groups.....
like 
 mydomain.com/demo   (username)
 mydomain.com/testpage (pages)
 mydomain.com/cakephp   (group)

i have created three database tables(Users,Pages,Groups) and three controllers with respectably , how can display like above controllers  routing.

$routes->connect( ':slug/*', ['controller' => 'Users', 'action' => 'view'],[  '_name' => 'users','pass' => ['slug'] ]    );
$routes->connect( ':slug/*', ['controller' => 'Pages', 'action' => 'view'],[  '_name' => 'pages','pass' => ['slug'] ]    );
$routes->connect( ':slug/*', ['controller' => 'Group', 'action' => 'view'],[  '_name' => 'group','pass' => ['slug'] ]    );

only working first route only....

Please help me  Unique URL implementation above three controllers


Thank you

--
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+unsubscribe@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.

Sunday, July 26, 2015

CakePHP 3 - hasMany through association

if I have an association exactly like in the CookBook here:
http://book.cakephp.org/3.0/en/orm/associations.html#belongstomany-associations

class StudentsTable extends Table  {      public function initialize(array $config)      {          $this->belongsToMany('Courses', [              'through' => 'CourseMemberships',          ]);      }  }    class CoursesTable extends Table  {      public function initialize(array $config)      {          $this->belongsToMany('Students', [              'through' => 'CourseMemberships',          ]);      }  }    class CoursesMembershipsTable extends Table  {      public function initialize(array $config)      {          $this->belongsTo('Students');          $this->belongsTo('Courses');      }  }
Student BelongsToMany Course  Course BelongsToMany Student
id | student_id | course_id | days_attended | grade
How do I find all Courses that given Student has Grade == "A"?
Would following code work fine?

$query = $this->Courses->find('all')
    ->contain(['Students', 'CourseMemberships'])
    ->where(['Students.id' => $student_id, 'CourseMemberships.grade' => 'A']);


--
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+unsubscribe@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.