Pass a variable to a model construct

2015-10-14 Thread Michael Houghton
My experience of this is only with Cake 2, so I don't know if it is 
possible in Cake 3, but if it is, please point me in the right direction.

I find myself writing model files which pass the same parameters to my 
methods!

For example

My "Settings" model might have:

public function getSetting($id) {

}

public function updateSetting($id, $data) {

}

Rather than pass the $id each time I call a method, it would be great to 
pass this once when I declare the setting, for example:

$Setting = new $this->Setting($id);

And then to call my methods, use:

$Setting->updateSetting($data);

Is doing something like this possible in either CakePHP 2 or 3.

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.


Cakephp 3 How to update multiple row data in a single query

2015-10-14 Thread Karthik Keyan


Hi all,

I have multiple rows in database.

I need to collect all the rows based on certain condition and change the 
value of particular column by removing a word from the column's value.

How it could be done with with cakePHP 3?

-- 
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: How can i load a model method in view file in cakephp 3

2015-10-14 Thread Marcelo Andrade
On Wed, Oct 14, 2015 at 9:23 AM, Zahidur Rahman  wrote:
> Hi Guys,
> How can i load a model method in view file in cakephp 3.

CakePHP is a MVC framework.  So you can't do this.

Pass the model data to the view via controller.

Regards.

-- 
MARCELO F ANDRADE | Belem, Amazonia, Brazil | http://about.me/mfandrade

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


How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-14 Thread heavyKevy
I have gone through the documentation, which is a bit too vague, and tried 
many things, but I still am getting an error that the template file is 
missing.

I had this working sending back a json response in 3.0 using ext='json', 
yet after updating to 3.1 it is broken.  

I checked the migration guide and tried changing ext  to _ext, setting up 
the Routes with:
Router::extensions(['json']);

in the controller method I am using the _serialize key which is supposed to 
render without the template:
$this->set('_serialize', ['salesPeople']);

The JsonView class does not appear to be loading and I don't see in the 
documentation where I am supposed to set it.
The documentation says ' you can automatically leverage the new view 
classes' By enabling RequestHandlerComponent in your application, and 
enabling support for the json and or xml extensions, but I have enabled it 
in the Initialize method of the controller and enabled the 'json' extension 
as mentioned earlier and it is still not working.

Here is the method in question:
public function getSalesPeopleSelectList() {
$this->request->accepts('json'); // No direct access via browser URL
$dealerId = $this->request->params['pass'][0];
$this->RequestHandler->renderAs($this, 'ajax');
//$this->viewClass = 'Json';
$this->loadModel('SalesPeople');
$salesPeople = 
$this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
  
//for salespeople options for autocomplete
$this->set(compact('salesPeople'));
$this->set('_serialize', ['salesPeople']);
}


When I enable the _ext = json I get the following error:

2015-10-14 06:57:36 Error: 
[Cake\Controller\Exception\MissingActionException] Action 
PurchasesController::getSalesPeopleSelectList.json() could not be found, or 
is not accessible.
Exception Attributes: array (
  'controller' => 'PurchasesController',
  'action' => 'getSalesPeopleSelectList.json',
  'prefix' => '',
  'plugin' => NULL,
)
Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
Stack Trace:
#0 
C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
 
Cake\Controller\Controller->invokeAction()
#1 
C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87): 
Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
#2 C:\WebServer\webdocs\Subaru\index.php(42): 
Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), 
Object(Cake\Network\Response))
#3 {main}

What have I missed?

-- 
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: How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-14 Thread Anthony GRASSIOT
Did you correctly specify the data type json in your ajax call ?
Le 14 oct. 2015 09:02, "heavyKevy"  a écrit :

> I have gone through the documentation, which is a bit too vague, and tried
> many things, but I still am getting an error that the template file is
> missing.
>
> I had this working sending back a json response in 3.0 using ext='json',
> yet after updating to 3.1 it is broken.
>
> I checked the migration guide and tried changing ext  to _ext, setting up
> the Routes with:
> Router::extensions(['json']);
>
> in the controller method I am using the _serialize key which is supposed
> to render without the template:
> $this->set('_serialize', ['salesPeople']);
>
> The JsonView class does not appear to be loading and I don't see in the
> documentation where I am supposed to set it.
> The documentation says ' you can automatically leverage the new view
> classes' By enabling RequestHandlerComponent in your application, and
> enabling support for the json and or xml extensions, but I have enabled
> it in the Initialize method of the controller and enabled the 'json'
> extension as mentioned earlier and it is still not working.
>
> Here is the method in question:
> public function getSalesPeopleSelectList() {
> $this->request->accepts('json'); // No direct access via browser
> URL
> $dealerId = $this->request->params['pass'][0];
> $this->RequestHandler->renderAs($this, 'ajax');
> //$this->viewClass = 'Json';
> $this->loadModel('SalesPeople');
> $salesPeople =
> $this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
> //for salespeople options for autocomplete
> $this->set(compact('salesPeople'));
> $this->set('_serialize', ['salesPeople']);
> }
>
>
> When I enable the _ext = json I get the following error:
>
> 2015-10-14 06:57:36 Error:
> [Cake\Controller\Exception\MissingActionException] Action
> PurchasesController::getSalesPeopleSelectList.json() could not be found, or
> is not accessible.
> Exception Attributes: array (
>   'controller' => 'PurchasesController',
>   'action' => 'getSalesPeopleSelectList.json',
>   'prefix' => '',
>   'plugin' => NULL,
> )
> Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
> Stack Trace:
> #0
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
> Cake\Controller\Controller->invokeAction()
> #1
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87):
> Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
> #2 C:\WebServer\webdocs\Subaru\index.php(42):
> Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request),
> Object(Cake\Network\Response))
> #3 {main}
>
> What have I missed?
>
> --
> 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.
>

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


How Can I Call Own Helper Function in External PHP File

2015-10-14 Thread Lakshmana Katragadda


External PHP file was in Web-root. i created one own helper class .now i 
want call that function from PHP file

Code:

$ReviewCount=$this->Search->getReviewsCount(); echo $ReviewCount

it was working view file but its showing error in External php file Fatal 
error: Using $this when not in object context

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


Controller Flash component error

2015-10-14 Thread Sathish Sukumar
Hi 

When I use this method - $this->Flash->success(__('Your post has been 
saved.')); in the tutorial the following error is encountered

"Call to a member function setFlash() on a non-object "

Please help me out.

Thanks,

Sathish

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


Use Bake with another PHP version

2015-10-14 Thread Sebastian S
Hi all 
I have trouble using bin/bake, because of my server setup (dedicated), I 
think. It uses PHP as CGI and in default the terminal uses PHP 4. 

(13:38:26) [webfiles] bin/cake bake all users
X-Powered-By: PHP/4.4.9
Content-type: text/html


Warning:  Unexpected character in input:  '\' (ASCII=92) state=1 in 
/mypath/webfiles/bin/cake.php on line 33

Parse error:  syntax error, unexpected T_STRING in 
/mypath/webfiles/bin/cake.php on line 33
(13:38:29) [webfiles]

Is there any way to call bake with another PHP version?

Thanks!!

Sebastian

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


File upload Issue after upgrading cakephp from 2.3.9 to to 2.7.5

2015-10-14 Thread Nicklas
 I have fixed most issues after the upgrade but one I just can't seem to 
solve. I hope someone can help me. I created a few years ago this upload 
form/functionality in the admin section to give the admin user the 
possibility to upload images for a property in a region. The admin user 
select the Region, then the Property then browse over his drive to select a 
file, enter the image alt 'description' and then finally hit the Upload 
Image button. This form worked perfect in cakephp version 2.3.9. But after 
the upgrade it fails with "Internal Server error" in all Windows browsers, 
it looks like it has a problem with the 'temp' file location of this file I 
know they have changed so much in cakePHP i just wonder what setting/folder 
is just for this temp filename when you submit the form...

I checked the /user/local/apache/domlogs, I checked the /var/log/messages. 
I also checked in the /app/tmp/logs/ nothing... I have enabled the debug 
option. nothing.. I have tried to put a die(); on several places, but I am 
just puzzled, the form works as supposed I can't get anything faulty, but 
as soon as I press the button Upload Image. the error comes with blank 
screen and error: Internal Server error www.domain.com/admin/uploads.

View

   Session->flash(); 
?>  
 Form->create('Upload', array('type' => 'file')); 
?> Form->input('region_id', array('label' => 'Select 
Region:')); ?> Form->input('property_id', array('label' => 
'Select Property:')); ?> Form->file('file'); ?> Form->input('description', array('label' => 'Image Alt = [Specify an 
alternate text for the image]:')); ?>   Form->submit(__('Upload Image', true)); ?>  

Controller

set('title_for_layout', 'Upload controller - '); // Retrieve the region 
list $this->set('regions', $this->Region->find('list', array( 'fields' => 
array('Region.id', 'Region.regionname'), 'order' => 'regionname', ))); // 
Retrieve the properties list $this->set('properties', 
$this->Property->find('list', array( 'fields' => array('Property.id', 
'Property.ref', 'Property.description'), 'order' => 'ref', ))); if 
(isset($this->request->data['Upload']['region_id'])) { // Image selected? if 
($this->request->data['Upload']['file']['name'] == '') { 
$this->Session->setFlash('Please, select an image to upload.'); 
$this->redirect($this->referer()); } // All required data is collected. // 
Prepare uploading file to the server and store in the db. // Check if folder 
exist to store the Image in. $this->Region->recursive = 0; $propertyid = 
($this->request->data['Upload']['property_id']); $property = 
($this->Property->findById($propertyid)); $propertyref = 
$property['Property']['ref']; $regionid = 
($this->request->data['Upload']['region_id']); $regionname = 
($this->Region->findById($regionid)); $cdest = 
$regionname['Country']['countryname']; // Set Folder -> Country $rdest = 
$regionname['Region']['regionname']; // Set Folder -> Regionname $destination = 
(ROOT.DS.WEBROOT_DIR.DS.'img'.DS.$cdest.DS.$rdest.DS); //debug($destination); 
//$destination = (App.imageBaseUrl.DS.$cdest.DS.$rdest.DS); 
//debug($destination); // Folder exist? $folder = new Folder($destination); 
$folderexist = $folder->cd($destination); // Returns False on failure. if 
($folderexist == false ) { // Create new folder. $folder->create($destination); 
} // Create the Filename. $tmp_name = 
($this->request->data['Upload']['file']['tmp_name']); $filename = 
($this->request->data['Upload']['file']['name']); $fileprefix = $propertyref; 
// New filename. $filext = substr($filename, -4); // Keep file extension. // 
Count the files in the destination folder. $dir = new Folder($destination); // 
Destination folder. $files = $dir->find('$propertyref.*', true); // Creates 
array with filenames. $counter = count($files); // Count the files. if 
($counter == 0){ // No such files $counter = $counter + 1; // First image. } 
$filemid = sprintf('%01d', $counter); // Add number to filename. $filename = 
($fileprefix.$filemid.$filext); // Put the parts together. // Check if the file 
exist. if (file_exists($destination.$filename)) { // Yes, we need to increase 
the counter. while (file_exists($destination.$filename)) { $counter = $counter 
+ 1; $filemid = sprintf('%01d', $counter); $filename = 
($fileprefix.$filemid.$filext); //debug($filename); }} // Upload the file to 
the server/folder. move_uploaded_file($tmp_name, $destination . $filename); // 
Prepare for writing to the database. $filesize = 
($this->request->data['Upload']['file']['size']); $createdt = date('Y-m-d 
H:i:s'); $description = ($this->request->data['Upload']['description']); if 
($description == '') { // Is the Tag/Description empty? $description = 
$filename; // Yes, we use the filename. } // Create the Array with correct name 
and fields for the DB. $this->request->data['PropertyImage']['filename'] = 
$cdest.DS.$rdest.DS.$filename; 
$this->request->data['PropertyImage']['filesize'] = $filesize; 
$this->request->data['PropertyImage']['description'] = 

Looking for a CakePHP Tutor with some help with MVC project

2015-10-14 Thread LSRX4EVER
Hello,

I am currently working on an internship web application that is utilizing 
CakePHP. Currently I have a very large mysql database schema and have been 
working slowly on developing and learning CakePHP. I am interested in 
finding a developer who is willing to freely devote some of their time in 
educating/assistanting me along with my project. I have dove through tons 
of documentation, forums and examples and it would be great to bounce a few 
questions or ideas with an educated cakephp developer. Please message me or 
email me if someone is interested.

Thanks,
Corey

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


Pesquisa de Frameworks PHP

2015-10-14 Thread cassiane silva
Oi gente, sou Cassiane estou fazendo meu TCC sobre frameworks PHP em visão 
de fazer o meu próprio para Trabalho de Conclusão em Analise e 
Desenvolvimento de Sistema 
Demora apenas 5 minutos e preciso muito que ao menos 10 respondam pois 
voces já utilizam o cake e provavelmente já usaram outro framework por 
favor gente é muito importante 
preciso de uma amostra de pelo menos 30 pessoas. 


Este é o link do google drive 
https://docs.googlem?usp=send_form 



Quem achar que é vírus ou etc... 
Pode deixar o email que eu envio por email até pq pode responder depois 
quem sabe. 
Obrigada gente nem que seja só por terem lido. 

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


dateFormat doesn't work anymore in cakephp 3.0

2015-10-14 Thread Filippo Giordano
Somebody knows how to format $this->Form->input in 'DMY'? The option 
dateFormat doesn't work anymore in cakephp 3.0. Thanks in advance.

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


New plugin ACL cakephp3

2015-10-14 Thread Rafael Abreu
Hello, I developed a plugin for acl cakephp3. Am new to the cakephp, it is 
three weeks I started to use it. As I saw that the community still needs a 
plugin acl decided to develop. The tutorial is in Portuguese, if anyone can 
translate it I thank you. Reviews and collaborations are welcome!

Thank you!

Link github: https://github.com/abreu1234/acl

-- 
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: How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-14 Thread Kevin Arnett
code that generated the URL:
$url = $this->Url->build(['controller' => 'Purchases', 'action' =>
'get_sales_people_select_list','_ext'=>'json']);
$url = $url . '/47';

The generated URL:
/purchases/get-sales-people-select-list.json/47

Is this not correct?

On Wed, Oct 14, 2015 at 4:40 PM, Anthony GRASSIOT 
wrote:

> Did you correctly specify the data type json in your ajax call ?
> Le 14 oct. 2015 09:02, "heavyKevy"  a écrit :
>
>> I have gone through the documentation, which is a bit too vague, and
>> tried many things, but I still am getting an error that the template file
>> is missing.
>>
>> I had this working sending back a json response in 3.0 using ext='json',
>> yet after updating to 3.1 it is broken.
>>
>> I checked the migration guide and tried changing ext  to _ext, setting up
>> the Routes with:
>> Router::extensions(['json']);
>>
>> in the controller method I am using the _serialize key which is supposed
>> to render without the template:
>> $this->set('_serialize', ['salesPeople']);
>>
>> The JsonView class does not appear to be loading and I don't see in the
>> documentation where I am supposed to set it.
>> The documentation says ' you can automatically leverage the new view
>> classes' By enabling RequestHandlerComponent in your application, and
>> enabling support for the json and or xml extensions, but I have enabled
>> it in the Initialize method of the controller and enabled the 'json'
>> extension as mentioned earlier and it is still not working.
>>
>> Here is the method in question:
>> public function getSalesPeopleSelectList() {
>> $this->request->accepts('json'); // No direct access via browser
>> URL
>> $dealerId = $this->request->params['pass'][0];
>> $this->RequestHandler->renderAs($this, 'ajax');
>> //$this->viewClass = 'Json';
>> $this->loadModel('SalesPeople');
>> $salesPeople =
>> $this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
>> //for salespeople options for autocomplete
>> $this->set(compact('salesPeople'));
>> $this->set('_serialize', ['salesPeople']);
>> }
>>
>>
>> When I enable the _ext = json I get the following error:
>>
>> 2015-10-14 06:57:36 Error:
>> [Cake\Controller\Exception\MissingActionException] Action
>> PurchasesController::getSalesPeopleSelectList.json() could not be found, or
>> is not accessible.
>> Exception Attributes: array (
>>   'controller' => 'PurchasesController',
>>   'action' => 'getSalesPeopleSelectList.json',
>>   'prefix' => '',
>>   'plugin' => NULL,
>> )
>> Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
>> Stack Trace:
>> #0
>> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
>> Cake\Controller\Controller->invokeAction()
>> #1
>> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87):
>> Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
>> #2 C:\WebServer\webdocs\Subaru\index.php(42):
>> Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request),
>> Object(Cake\Network\Response))
>> #3 {main}
>>
>> What have I missed?
>>
>> --
>> 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.
>>
> --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/31AlwVDJmv8/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

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


How can i load a model method in view file in cakephp 3

2015-10-14 Thread Zahidur Rahman
Hi Guys,
How can i load a model method in view file in cakephp 3.

Thanks
Zahid

-- 
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: How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-14 Thread heavyKevy
I discovered a bug in the Route.php file.
the reg expression used for finding extensions only works if no parameters 
are passed in the URL.
I have temporarily modified my Routes.php file to find the extension 
anywhere in the string and used str_replace to remove the .json from the 
url and I no longer get the action missing error.
I still get the template missing error though.

On Wednesday, October 14, 2015 at 2:02:24 PM UTC+7, heavyKevy wrote:
>
> I have gone through the documentation, which is a bit too vague, and tried 
> many things, but I still am getting an error that the template file is 
> missing.
>
> I had this working sending back a json response in 3.0 using ext='json', 
> yet after updating to 3.1 it is broken.  
>
> I checked the migration guide and tried changing ext  to _ext, setting up 
> the Routes with:
> Router::extensions(['json']);
>
> in the controller method I am using the _serialize key which is supposed 
> to render without the template:
> $this->set('_serialize', ['salesPeople']);
>
> The JsonView class does not appear to be loading and I don't see in the 
> documentation where I am supposed to set it.
> The documentation says ' you can automatically leverage the new view 
> classes' By enabling RequestHandlerComponent in your application, and 
> enabling support for the json and or xml extensions, but I have enabled 
> it in the Initialize method of the controller and enabled the 'json' 
> extension as mentioned earlier and it is still not working.
>
> Here is the method in question:
> public function getSalesPeopleSelectList() {
> $this->request->accepts('json'); // No direct access via browser 
> URL
> $dealerId = $this->request->params['pass'][0];
> $this->RequestHandler->renderAs($this, 'ajax');
> //$this->viewClass = 'Json';
> $this->loadModel('SalesPeople');
> $salesPeople = 
> $this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
>   
> //for salespeople options for autocomplete
> $this->set(compact('salesPeople'));
> $this->set('_serialize', ['salesPeople']);
> }
>
>
> When I enable the _ext = json I get the following error:
>
> 2015-10-14 06:57:36 Error: 
> [Cake\Controller\Exception\MissingActionException] Action 
> PurchasesController::getSalesPeopleSelectList.json() could not be found, or 
> is not accessible.
> Exception Attributes: array (
>   'controller' => 'PurchasesController',
>   'action' => 'getSalesPeopleSelectList.json',
>   'prefix' => '',
>   'plugin' => NULL,
> )
> Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
> Stack Trace:
> #0 
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
>  
> Cake\Controller\Controller->invokeAction()
> #1 
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87):
>  
> Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
> #2 C:\WebServer\webdocs\Subaru\index.php(42): 
> Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), 
> Object(Cake\Network\Response))
> #3 {main}
>
> What have I missed?
>
>

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