You want to do something like this where $this->Session->read() returns the current authenticated user:- $this->Table->find( 'all', array( 'conditions' => array('Table.user_id' => $this->Session->read("Auth.User.id")) ) ); ...
security,unit-testing,cakephp,cakephp-3.0
That is to be expected, as you're not sending the necessary security token, which is what the security component requires. Just look at your generated form, it will contain hidden inputs for the _Token field, with the subkeys fields and unlocked, where fields will contain a hash and possibly the...
find() method returns a query object. Since you want the single entity that matches that slug, call first() on the query object: $article = $this->Articles->findBySlug($slug)->first(); ...
You need to use FormHelper Templates. From migration guide: The separator, between, and legend options have been removed from radio(). You can use templates to change the wrapping HTML now. The div, before, after, between and errorMessage options have been removed from input(). so in your case use this echo...
postgresql,cakephp,cakephp-3.0
Either rename the view variable $parentMenus to $parents or in the view change echo $this->Form->input('parent_id'); to echo $this->Form->input('parent_id', ['options' => $parentMenus]); ...
i didn't understand your question . but i will it give blind shot anyway. i think you you want to support multiply cakephp auth. auth objects are they for that purpose. you can attach many objects and cakephp will check them sequentially , if any can identify the request, access...
If you want all fields from logged user, you can use this in your view. $user = $this->Session->read('Auth.User')); This will return all storage data from users ( username, filename, all fields from user table) ...
You have a fundamental misunderstanding here: the "remote file" in an FTP connection is something remote from you - a file on another server somewhere, for instance. In your case, I think the file you're trying to serve is "local" in this sense, but you want a way of getting...
This would return all the name values that appear in more than one table: select name from (select distinct name from table1 union all select distinct name from table2 union all select distinct name from table3 union all select distinct name from table4) temp group by name having count(*) >...
cakephp,methods,sql-update,edit
You're not using Cake's standard naming conventions so you need to make sure you override model attributes that Cake would normally auto-generate. Cake expects the primaryKey to be id which it uses to determine whether to insert or update a record. As you're using eventDate_id you need to tell Cake...
As you've figured it's possible to configure the flash element when rendering it, to change this globally, configure the component instead. If all you want to do is to change the classname, then you can use the class parameter in the flash configuration options params setting: $this->loadComponent('Auth', [ // ......
Once you have activated the php_intl.dll in the php.ini file you also need to copy the dll files that php_intl.dll uses from the PHP folder to the Apache/bin folder. I am not a XAMPP user so I am not sure of the actual folder names copy xampp/php/icu*.dll to xamp\apache\bin Also...
Cakephp doesn't have a changelog file in the repository. You can either browse trough the github versions for a short textual changelog: https://github.com/cakephp/cakephp/releases Alternatively you can read the changes in the cakephp news: http://cakephp.org/pages/news Or if you want see the granular changes you can browse the source code by tags:...
If you re-run the script immediately, you should see those queries disappearing. These queries are being used to grab data for generating schemas and other metadata, and by default this should happen rather rarely as the data is being cached, given that cacheMetadata is enabled in your apps datasource configuration....
From what you've described your associations look wrong. They should be something like:- User <?php class User extends AppModel { public $hasMany = array( 'Car' ); public $hasAndBelongsToMany = array( 'Address' ); } Car <?php class Car extends AppModel { public $belongsTo = array( 'User' ); public $hasAndBelongsToMany = array(...
Change 'unique' => array( 'rule' => array('isUniqueUsername'), 'message' => 'This username is already in use' ) To 'unique' => array( 'rule' => 'isUnique', 'message' => 'This username is already in use' ) You do not need that function to check for uniqueness, Cake does it for you with magic....
$articles = $this->Model->find() ->select(['fields_you_want_from_this_Model']) ->contain(['Assoc_Model' => function($q) { return $q ->select(['fields_you_want_from_the_associated_model']); }]); ...
if you allowed to use external PHP libraries; I'd like to suggest this method: https://github.com/php-curl-class/php-curl-class // Requests in parallel with callback functions. $multi_curl = new MultiCurl(); $multi_curl->success(function($instance) { echo 'call to "' . $instance->url . '" was successful.' . "\n"; echo 'response: ' . $instance->response . "\n"; }); $multi_curl->error(function($instance) {...
Better performance : Version 3 incorporates performance improvements to the bootstrap process, the routing process, and several parts of process for generating helper templates. Enhanced components and helpers: Version 3 provides enhanced support for “flash messages” with its new FlashHelper and FlashComponent. In addition, the CookieComponent has been enhanced,...
The query you are hitting is not correct,try this:- $this->Product->updateAll(array('Product.rating' => "'".$this->request->data['Product']['rating']."'",'Product.review' => "'".$this->request->data['Product']['review']."'"),array('conditions'=>array('Product.id' => $prod_id))); Note:- )of first array is misplaced. it must be closed before condition array. in condition array it will be Product.id not prod_id....
validation,cakephp,cakephp-3.0
When using that style of adding unique rules, you'll have to pass the message to the isUnique() calls second argument, ie $rules->add($rules->isUnique(['email'], 'Este email já encontra-se em uso.')); That is because you are technically creating nested callables this way ($rules->isUnique() creates one, and $rules->add() creates another one), and defining options...
If you need to have the ability to change the password in the edit form, then you'll have to make sure that it is being dropped before it is being marshalled in case no data is being provided. This can be achieved using the Model.beforeMarshal event in your Users table...
Yes you can do this if you use View Elements. The best way to do this would be to create an Element template for the customers index template and then output this in both your Customers/index and Main/index templates like this:- // Output Template/Element/customers.ctp echo $this->Element('customers'); The Element template will...
php,unit-testing,cakephp,phpunit,cakephp-3.0
The problem was in the Command prompt, when I run my tests in Windows PowerShell everything was OK.
Your OR array is not correctly defined. You have created an array with 3 identical keys (i.e., the 'AND') Instead of this: 'OR' =>array( 'AND' => array( 'Event.start >=' => $search_from, 'Event.end <=' => $search_to), 'AND' =>array( 'Event.end >' => $search_from, 'Event.end <=' => $search_to), 'AND' =>array( 'Event.start >=' =>...
cakephp,authentication,model,cakephp-3.0
What other way is there to get the id from the authenticated user in a model? Simply pass it to a model method: public function someModelMethod($userId, array $postData) { // Do something here, move your code from the controller here return $something; } public function someControllerAction() { $this->set('data', $this->Model->someModelMethod(...
This would have probably been a comment, but since I don't have enough reputation... I guess you are trying to change/assign the value to hidden field on a particular, action. I just assume a click event. Jquery required $('.classNameOfClickableObjt').clilck(function(){ $('input[name="data[Message][parent_id]"]').val(parentid); /*Another alternative, you might assign attribute, like $('input[name="data[Message][parent_id]"]').attr('value', parentid); */...
You can use raw expressions instead In your case there's no need to use the function builder, as you're passing safe, hardcoded values that don't need to be inserted into the query as bound parameters. You could instead simply use a raw expression like $query->newExpr('SUBSTRING_INDEX(`name`, "", -1)') - Arbitrary functions...
CakePHP 3's Migration plugin is a Phinx wrapper plugin, so adding records can be done using the up() method:- public function up() { // Save records to the newly created schema } public function down() { // Remove records } For example, you could add a new user using TableRegistry...
Should be: echo $this->Form->create('EventDate'); // notice the capital CamelCase Side note: The info that displays in the fields will be out-of-date, since you 1) get the data from the DB and set to var, THEN do the save based on posted data. Another side note: There are quite a few...
Take a look at virtual properties: http://book.cakephp.org/3.0/en/orm/entities.html#creating-virtual-properties. Looking at http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#finding-key-value-pairs could say you can use virtual properties.
Check if you have loaded jQuery in your layout (include it in the head of the document if you want it to work like this) It's $('#open'), not $('open'). Use jQuery selectors just like in css. ...
Sry to say this but your use of saveall is awkward. With save you usually want to create new records and don't specify an id field. So perhaps you get ploblems cause cakephp expects an update and one of the id's is already existent in the database. Btw. you can...
As has been pointed out serveral times to you in the comments you should never store passwords as plain text in your database. This is regardless to whether or not they are being directly used by your app or not. As Anthony mentioned in his comment to your question you...
Good answer here : Cake PHP 2.4.x. AuthComponent login() always return true; Also read this : http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in...
Did you use a proper IDE? Did you check the amount of attributes you may use for postLink()? The documentation clearly states: postLink($title, $url, $options). Why are you using a forth then? Of course that one will be ignored. So it should be this instead: $this->Form->postLink( "<i class='fa fa-remove'></i>", //...
make the pagination data available in the element i.e $this->params['paging'] //index method if ($this->params['requested']) return array('images'=>$this->paginate('WebSite'), 'paging' => $this->params['paging']); $this->set('images', $this->paginate('WebSite') ); then in your home.ctp do this $images = $this->requestAction(array('controller'=>'websites','action'=>'index')); // if the 'paging' variable is populated, merge it with the already present paging variable in $this->params. This will...
Check the docs, it's all well explained. Request::input() by default returns data in raw string format, if you need it to be converted, pass a callback to the method to handle that, for example json_decode. $this->request->input('json_decode'); See also Cookbook > Controllers > Request & Response Objects > XML or JSON...
Build the conditions like - 'conditions' => array( 0 => array('View.id = UserView.view_id'), 1 => array('UserView.user_id' => $user_id), 3 => 'UserView.like => 1 OR UserView.like => 0' ), Or with using OR - 'conditions' => array( 0 => array('View.id = UserView.view_id'), 1 => array('UserView.user_id' => $user_id), 2 => 'UserView.like IN...
You will want to setup a custom validation rule for testing that the 'full name' is unique. For example, in your model add a new method for validation like this:- public function validateUniqueFullName(array $data) { $conditions = array( 'first_name' => $this->data[$this->alias]['first_name'], 'last_name' => $this->data[$this->alias]['last_name'] ); if (!empty($this->id)) { // Make...
Use the Hash utility to rewrite the results returned before setting the data for the View:- class LeadPostsController extends AppController { public $components = array('RequestHandler'); public function index() { $records = $this->LeadPost->find('all', ['limit' => 20]); $this->set(array( 'leadposts' => Hash::extract($records, '{n}.LeadPost'), '_serialize' => 'leadposts' )); } } Here Hash::extract($records, '{n}.LeadPost') will...
Auth component shares Session class For Cakephp3 At config/app.php we can set the timeout. 'Session' => [ 'defaults' => 'php', 'timeout'=>24*60//in minutes ], For Cakephp2 in your Config/core.php Configure::write('Session', array( 'defaults' => 'php', 'timeout' => 31556926 //increase time in seconds )); ...
I looked a little further on this and found the solution: To find all items, that belong to category.id 1 AND 2 (not OR) I just had to add a 'group' parameter to my find like this: $options['group'] = array('Item.id HAVING COUNT(DISTINCT Categorie.id) > 1'); The complete query (working): $kategories...
Your first error is because /home/SOME_NAME/public_html/OLD_DOMAIN_NAME/tmp/cache/ is not writeable. Make sure that tmp has the correct file permissions; it needs to be writeable by the web server user. Otherwise your issue appears to be that the database config is wrong so the app cannot connect to the database. Check app/config/database.php...
php,mysql,validation,cakephp,cakephp-2.3
Maybe some custom validation like this: public $validate = array( 'someField1' => array( 'rule' => array('cantBeSame'), 'message' => 'someField1 cant be the same as someField2.' ), 'someField2' => array( 'rule' => array('cantBeSame'), 'message' => 'someField2 cant be the same as someField1.' ) ) public function cantBeSame(){ return ( $this->data['Somemodel']['someField1'] !=...
Normally If we need to use normal file in cakephp We need to store that file into the webroot folder of the cakephp. And the way to access is siteurl/filename.php Hope this will help you ...
$this->request->data cannot be accessed from within the model. This data is only accessible from the controller. When you attempt to save data to a model from the controller (e.g. $this->User->save($this->request->data))) you are setting the User model's data attribute. In other words, this is happening:- $this->User->data = $this->request->data; So in your...
You assumption is wrong. You can put enhancements/feature requests in there as well.
cakephp,pagination,cakephp-2.0
i have got solution to my problem , here it is . I have used a code in view page , here $search variable i have setted data from controller. $search); $this->Paginator->options(array( 'url' => $urlParamAr )); echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled')); echo $this->Paginator->numbers(array('first' => 'First page')); echo...
I've found that my mistake actually was in the newEntity() part! Before(Broken): $newEntity = $this->newEntity($inputData]); After(Fixed): $newEntity = $this->newEntity($inputData, ['associated' => ['Participants']]) And BEFORE executing newEntity I add the id's to the data list as following: $inputData['participants'] = [ '_ids' => [10, 12] ]; ...
You used $this->set('results', $this->Application->find('all')); in your controller, and in your view you are looping with a different variable. "results" should be your variable in foreach as set in your controller. That's just by the way. To answer your question, you should use count. if(count($results) > 0){ //Do whatever u like...
Your array for your GoodStock association should be a lower-underscored version of the association name. Plus, it probably won't be a one-dimensional array thus it's a hasMany association. You can find more information here. So your code should be moreless as: $data = [ 'brand' => 'brand', 'name' => 'name',...
cakephp,cakephp-2.0,cakephp-2.3
If you want to genereate multiple path segments, then you have to pass them as separate values, like echo $this->Html->link('Tiny MCE plugin', array( 'controller' => 'pages', 'plugin' => false, 'action' => 'display', 'testtinymce', 'testtinymce', // ... )); See also Cookbook > Development > Routing > Passed Arguments...
php,cakephp,iis,iis-7.5,cakephp-3.0
@ADmad helped me figure this out. It turns out that this had nothing to do with web.config in IIS. It isn't a CakePHP 3.0 specific thing either. According to CakePHP IRC the CakePHP 3.x and CakePHP 2.x routing is exactly the same. This is simply IIS PHP weirdness. The solution...
strtotime will not recognize that expression. Do it with mysql - 'conditions'=>array( 'Renewal.NextRenewalDate <=' => 'DATE_ADD(NOW() + INTERVAL `Renewal`.`NextRenewalDate` DAY)' ) ...
cakephp,cakephp-2.0,has-and-belongs-to-many
I think you're problem relates to the fact that you are not using CakePHP's naming conventions. From the look of the query being generated Cake doesn't know how to correctly alias the join table, hence getting an AppModel alias in your query. I suspect that this is causing issues when...
Your conditions need to be ['Transaction.id' => $client_id, 'Transaction.name !=' => 'Facturation']. Multiple conditions of the conditions array are interpreted as 'AND' conditions. So your query would look like:- $transaction_query = $this->Transaction->find('all', [ 'limit' => $countList, 'fields' => [ 'Transaction.client_id', 'Transaction.name', 'Transaction.created', 'Transaction.message_id', 'Transaction.credit' ], 'conditions' => [ 'Transaction.id' =>...
I have found the solution. I have read the cookbook again and I noted in one of the examples snippets 'associated' => ['Tags', 'Comments.Users'] I have applied this to my controller and it now works. It is saving on all levels. $user = $this->Users->patchEntity($user, $this->request->data, [ 'associated' => ['Employees', 'Employees.Courses']...
Table::save() returns the entity with updated ids. So store the return value in a variable and use appropriate property of the entity.
You are looking at custom formatted debug output, not a logical representation of the object (use for example var_dump() to see the difference). Until recently, when dumping an entity via debug(), various hidden properties were being made visible, including the $_properties property, which holds a map of the available properties...
For instance, once a user is logged in, I have to recover some informations about him. The User.id, User.name, etc. are recovered using the SessionHelper as follow : Not a good idea, the best is to set the user data from the auth component to the view. For example...
What you are doing there won't work for various reasons. You cannot pass SQL snippets in the value part of the conditions array, it will be escaped and you'll end up with a string comparison like created = 'CURDATE()', you'd either have to pass the whole condition as a string,...
cakephp,cakephp-3.0,cakephp-bootstrap-ui
This appears to be badly documented, but to configure any of the settings for a helper you need to pass them as an array when you load it. So for example, if you are loading the Paginator helper inside your AppView you would pass prevlike this:- $this->loadHelper( 'Paginator', [ 'className'...
cakephp,plugins,components,cakephp-3.0
You can use Plugin::path() to retrieve the absolute path to your plugin, so you don't have to hardcode it. Plugin::path('YourPlugin') . 'webroot' . DS . 'RangeMessage.xml' See also API > Cake\Core\Plugin::path()...
That's how HTML works, values of disabled elements are not being sent. Use a hidden field just like it would automatically be used for multiple type selects or checkboxes. It should have the same name as the actual field and be placed before it. That way the hidden value will...
With this AJAX form submission approach, you will not be able to upload file using ajax. If you don't like using a third-party plugin like dropzone.js or Jquery file upload, you can use XMLHttpRequest. An example below: $('#newcatform').on('submit', function(ev){ ev.preventDefault(); var forms = document.querySelector('form#newcatform'); var request = new XMLHttpRequest(); var...
You can configure the DateWidget template when initializing the Form helper // in MyController.initialize() $this->loadHelper('Form', [ 'dateWidget' => '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}{{meridian}}' ]); or you can override the template using the templates function in the form component $this->Form->templates([ 'dateWidget' => '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}{{meridian}}' ]); @see http://book.cakephp.org/3.0/en/views/helpers/form.html#customizing-the-templates-formhelper-uses...
cakephp,has-and-belongs-to-many,cakephp-3.0
You need to camelCase the View variable for the options for the magic to happen, so it should be $userRoles rather than $user_roles:- $this->set('userRoles', $this->Users->UserRoles->find('list', ['id', 'role_name'])); Cake will then know to associate the variable with the form field. Otherwise you will have to specify the variable used for the...
This is job for matching() method, which will create INNER JOIN with RefundProducts, so you will get only Products that have some RefundProducts. Conditions in contain limit only fetched associations $result = $this->Products->find() ->contain(['RefundProducts' => function ($q) use ($refund_condition) { return $q->where($refund_condition); }]) ->matching('RefundProducts') ->distinct(['Products.id']); I'm not sure what $refund_condition...
For me it looks like a problem with mod_rewrite, look on http://m.gratuito24.com/index.php/ads/index/showAds:goods/language:bg.html, index.php part is important, first thought: no mod_rewrite on server, second: something wrong with .htaccess...
Use BETWEEN: $conditions = array( 'Tapplicant.AppDate BETWEEN ? AND ?' => array( $start, $end, ) ); Read more about complex find conditions in CakePHP 2 here: http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#complex-find-conditions...
php,cakephp,plugins,cakephp-2.0
As stated in the comments your code is correct, but you need a PagesController in your plugin. http://book.cakephp.org/2.0/en/plugins/how-to-create-plugins.html#plugin-views
The available shells are being retrieved by scanning the shell folders for .php files. Exclusions are only made to the list of shells that live in the main app and the core (AppShell, CommandListShell and CompletionShell are being hidden by default), the plugin shell list is not going to be...
php,cakephp,zend-framework,google-plus,gdata
Zend_Gdata uses ClientLogin which was deprecated as of April 20, 2012 and turned off on May 26 2015. This code will not longer work you need to switch to using Oauth2. You can use the current Google PHP client library to authenticate then use the access token created there to...
first create a view for your controller action. the view file name has to be conventionally named i.e underscored version of the cooresponding controller action e.g if you have action named viewArticle the view file w'd be view_article.ctp public function viewArticle(){ $data = $this->{$this->modelClass}->find('all',$conditions); // here set your data to...
You are passing a query object to Table::delete(), that's not how it works, the method expects an entity, which you have to fetch in beforehand. Simplified example $this->delete($this->get($id)); See also Cookbook > Database Access & ORM > Deleting Data Cookbook > ... ORM > Retrieving Data ... > Getting a...
Cake php proivide a very nice way to execute function without being login into the system. that is $this->Auth->allow() in AppController. So In App controller you will get this line $this->Auth->allow() somewhere. in that just give those action names which are going to change language . that functions starts working...
Remove double quote from $this->set('messages', "$messages"); it should be $messages = array("Apples", "Oranges", "Pears"); $this->set('messages', $messages); and in view you can <?php pr($messages); ?> ...
Maybe this could help you? http://api.cakephp.org/3.0/class-Cake.Database.Schema.Collection.html#_describe It seems to be the samen functionality......
In boostrap or in App Controller, paste this if(Configure::read('debug')){ ConnectionManager::config('deployment'); } this change the default config of database when the debug is true....
css,.htaccess,cakephp,mod-rewrite,cakephp-2.6
I solved my problem, the solution is firstly (in my case) delete the three .htaccess files and edit this line in app/config/core.php //Configure::write('App.baseUrl', env('SCRIPT_NAME')); to this: Configure::write('App.baseUrl', env('SCRIPT_NAME')); it works for me, thanks guys anyway....
Something like this should do it: public $hasMany = array( 'Post' => array( 'className' => 'Post', 'foreignKey' => 'forum_id', 'dependent' => false, 'order' => 'Post.created ASC' //order the Posts in ascending order based on whe they were created ) Assuming you have a created column in your database table. Edit:...
Add the userModel setting to use a model other than 'User' for your login/users: 'authenticate' => array( 'Form' => array( 'passwordHasher' => 'Blowfish', 'userModel' => 'QuanTriVien' // <-- ADD THIS ) ) Details here....
In Your Controller if ($this->request->is('post')) { $this->OlxProduct>create(); if(!empty($this->data)) { //Check if image has been uploaded if(!empty($this->data['OlxProduct']['image_field_name']['name'])) { $file = $this->data['OlxProduct']['image_field_name']; //put the data into a var for easy use $ext = substr(strtolower(strrchr($file['name'], '.')), 1); //get the extension $arr_ext = array('jpg', 'jpeg', 'gif'); //set allowed extensions if(in_array($ext, $arr_ext)) { //do the...
The Problem: According to the CakePHP 2.0 book: Due to the limitations of HTML itself, it is not possible to put default values into input fields of type ‘file’. Each time the form is displayed, the value inside will be empty. While I'm sure there are ways you could hack...
php,url,cakephp,get,cakephp-1.3
From the Cakephp 1.3 book: URL: /contents/view/chapter:models/section:associations Mapping: ContentsController->view(); $this->passedArgs['chapter'] = 'models'; $this->passedArgs['section'] = 'associations'; $this->params['named']['chapter'] = 'models'; $this->params['named']['section'] = 'associations'; So you should use: $this->params['named']['name1'] $this->params['named']['name2'] ...
There's no way to do this. See related question: Dynamically set value of a file input. Most browsers block against setting the value attribute on input type file for security reasons so that you can't upload a file without the user's input. However, in the interests of showing the user...
find solution for my problem to avoid duplication of data,This link helps -> Validating multiple fields with the same name. All i have to do is put this code ->array('validate' => 'true')<- in this line if ($this->Group->save($this->request->data),array('validate' => 'true')) { and all done no need to disable the selected list...
database,datetime,cakephp,insert
Your problem is in view :) Change report to Report. Now when you are saving $this->request->data its trying to find Report key to be able to save , or report field in your database. If you dont want change this , in controller you can save $this->request->data['report'] Edit Also if...
That of course won't work, view cells do not support the use of components, altough they can be thought of like "mini-controllers", they are not actually controllers in the terms of CakePHPs MVC system. Depending on whether the cookies are encrypted, you can either use the request object to fetch...
You could probably use ur old app as 3th party library in cakephp 3.0. But the cleaner and most likely easier way would be the port of application. If you did your mvc job good it should be a lot of copy pasting. Cakephp is convention over configuration so the...