cakephp-3.x

cakephp 3.x mail is not working properly in live server

泪湿孤枕 提交于 2019-12-02 07:32:06
I am using cakephp 3.x. The email is working properly in localhost but not in case of live server. It is simultaneously giving error like "Transport class "SMTP" not found.".I have been stuck from long time. Please provide good solution for it.Why it is happening and what should I have to do? here is my config/app page 'EmailTransport' => [ 'default' => [ 'className' => 'SMTP', // The following keys are used in SMTP transports 'host' => 'ssl://smtp.gmail.com', 'port' => 465, 'timeout' => 30, 'username' => 'mardshehenshah@gmail.com', 'password' => '*******', // 'client' => null, // 'tls' =>

Full URLs in emails in CakePHP unittest

北城余情 提交于 2019-12-02 05:52:31
I would like to get full URLs inside emails that get triggered by my tests in CakePHP 3.2. I tried with the full-options for $this->Html->image('image.jpg', ['fullBase' => true]) and $this->Url->build('/', true) but they don't seem to work in tests. How can I force full URLs in emails while testing? There is no host when running an app in the CLI environment as it's not a web request. You'll have to configure the base URL on your own. Quote from the docs: App.fullBaseUrl The fully qualified domain name (including protocol) to your application’s root. This is used when generating absolute URLs.

How to compare two fields/columns in a condition?

蹲街弑〆低调 提交于 2019-12-02 05:33:38
问题 I am having a hard time trying to figure out how to get a sub-query working. Imagine I have: $schools ->select($this->Schools) ->select([ 'pupilcount' => $this->Pupils ->find() ->select([ $this->Pupils->find()->func()->count('*') ]) ->where([ 'Pupils.school_id' => 'Schools.id', ]), The problem I am experiencing (I think) is that Schools.id is always 0 and so the count is returned as 0. I can pull out the Pupils join and it shows Pupils there. I tried changing my code to add a: ->select(['SCID

How to compare two fields/columns in a condition?

巧了我就是萌 提交于 2019-12-02 00:12:38
I am having a hard time trying to figure out how to get a sub-query working. Imagine I have: $schools ->select($this->Schools) ->select([ 'pupilcount' => $this->Pupils ->find() ->select([ $this->Pupils->find()->func()->count('*') ]) ->where([ 'Pupils.school_id' => 'Schools.id', ]), The problem I am experiencing (I think) is that Schools.id is always 0 and so the count is returned as 0. I can pull out the Pupils join and it shows Pupils there. I tried changing my code to add a: ->select(['SCID' => 'Schools.id']) and reference that in the sub-query but doesn't work, it will always return 0 for

Subqueries in CakePHP 3?

此生再无相见时 提交于 2019-12-01 22:03:43
I have two tables products and product_categories that are associated through a third table, products_categories_products , according to CakePHP BelongsToMany conventions (Edit: these associations are established in ProductsTable.php and ProductCategoriesTable.php ). I want to generate a list of product categories, using the image from the best selling products to represent each category. I can achieve my desired outcome using the following function: public function findImages(Query $query, array $options) { $query->select([ 'ProductCategories.id', 'ProductCategories.name', 'ProductCategories_

cakephp 3.x Saving Nested (deep) Association

浪子不回头ぞ 提交于 2019-12-01 21:21:21
问题 I have product data coming from a 3rd party service call that I then create an object from and save to my MySQL DB. My models are as follows: 'products' hasMany>> 'product_skus' hasMany>> 'product_sku_attributes' table relationships In my ProductsTable.php initialize() method I have: $this->hasMany('ProductSkus', [ 'foreignKey' => 'product_no', 'dependent' => true, ]); In my ProductSkusTable.php initialize() method I have: $this->hasMany('ProductSkuAttributes', [ 'foreignKey' => 'product_sku

cakephp 3.x Saving Nested (deep) Association

試著忘記壹切 提交于 2019-12-01 18:28:40
I have product data coming from a 3rd party service call that I then create an object from and save to my MySQL DB. My models are as follows: 'products' hasMany>> 'product_skus' hasMany>> 'product_sku_attributes' table relationships In my ProductsTable.php initialize() method I have: $this->hasMany('ProductSkus', [ 'foreignKey' => 'product_no', 'dependent' => true, ]); In my ProductSkusTable.php initialize() method I have: $this->hasMany('ProductSkuAttributes', [ 'foreignKey' => 'product_sku_id', 'bindingKey' => 'id', 'propertyName' => 'product_sku_attributes', 'dependent' => true, ]); My

How to define CSRF token in ajax call in Cakephp 3. Also How CSRF can be off for some ajax requests

谁都会走 提交于 2019-12-01 16:39:58
In Cakephp3 when the Csrf component is enabled. How I can use it in ajax call. In this beforeSend parameter of ajax csrf token is set in header. What is the value of csrfToken . As it gives error csrfToken is not defined beforeSend: function(xhr){ xhr.setRequestHeader('X-CSRF-Token', csrfToken); }, Also how can I disable Csrf component for some ajax calls. The CSRF component writes the current token to the request parameters as _csrfToken , you can get it via the request objects param() method (or getParam() as of CakePHP 3.4): setRequestHeader('X-CSRF-Token', <?= json_encode($this->request-

How to define CSRF token in ajax call in Cakephp 3. Also How CSRF can be off for some ajax requests

为君一笑 提交于 2019-12-01 15:40:23
问题 In Cakephp3 when the Csrf component is enabled. How I can use it in ajax call. In this beforeSend parameter of ajax csrf token is set in header. What is the value of csrfToken . As it gives error csrfToken is not defined beforeSend: function(xhr){ xhr.setRequestHeader('X-CSRF-Token', csrfToken); }, Also how can I disable Csrf component for some ajax calls. 回答1: The CSRF component writes the current token to the request parameters as _csrfToken , you can get it via the request objects param()

How to use a custom format for multi-column display fields?

主宰稳场 提交于 2019-12-01 07:50:06
问题 Is anyone aware of a way of expanding the 'normal' uses of this (it's id by default and easily changed to field1 )? I have one displayField sets follows: $this->displayField(['name', 'desc']); Which displays as Name; Description when called in a template file. I know it's a fudge, but it there a way I can manipulate this to have it display Name - Description for example, just by using the displayField ? 回答1: Use a virtual field, and specify that to be used as display field instead of using