cakephp-3.0

How to configure saving strategy (append) for belongsToMany Association?

梦想与她 提交于 2019-12-12 04:22:41
问题 i have a belongsToMany association which deletes joinTable data because i just put new connections inside the entity to be persited. So i read here about the 2 strategys: append and replace. Replace is the default one. But i could not find out yet how to set it to append strategy? 回答1: You can define belongsToMany relation with saveStrategy keyword which accept either append or replace. So code should be like $this->belongsToMany('Articles', [ 'joinTable' => 'articles_tags', 'saveStrategy' =>

Cakephp 3.x show me empty row with my custom query

吃可爱长大的小学妹 提交于 2019-12-12 04:20:53
问题 I made a custom query in my cakephp 3.0, but when I wanna display the data in a table, the rows are empty. This is my function in controller: public function estadisticas() { $conn = ConnectionManager::get('default'); $stmt = $conn->execute('SELECT c.nombre, c.idComplejo, t.canchaFK, count(*) AS cantidadTurnos FROM turno t inner join complejo c inner join ciudad cc inner join cancha ca inner join usuario u on t.canchaFK=ca.idCancha and c.idComplejo=ca.complejoFK and u.idUsuario=t.usuarioFK

What are the acceptable types used in the Class TypeMap in Cake 3.x?

大城市里の小女人 提交于 2019-12-12 04:16:14
问题 Situation using cake 3.2.4 Was using the method addDefaults() to set the type decimal . Was wondering the following: what other types are there that I can set? is it possible to set precision and scale when setting decimal in the method addDefaults() Code that prompted that thinking $this->paginate['fields'] = [ 'id', 'title', 'start' => 'start_date', 'end' => 'end_date', 'revenue', 'costs' => 'total_costs', 'collections' ]; $paginationQuery = $event->subject()->query; $paginationQuery -

CakePHP 3 creating XML view

女生的网名这么多〃 提交于 2019-12-12 04:06:23
问题 I need to convert an array to an XML response. The objective is to write a function within a plugin controller and call it, which would return an XML response. I've been trying this below mentioned code from the CakePHP manual. namespace App\Controller; class ArticlesController extends AppController{ public function initialize(){ parent::initialize(); $this->loadComponent('RequestHandler'); } public function index(){ // Set the view vars that have to be serialized. $this->set('articles',

Cakephp 3 - Save associated belongsToMany (joinTable)

牧云@^-^@ 提交于 2019-12-12 03:59:50
问题 i have a question about saving a new entity with an association which is a belongsToMany relation. Just a quick introduction. I have something like a settings table and a setting_values table. The user is connected to the settings by a joinTable called users_settings. So in summary: settings: id | name setting_values: id | setting_id | name | value | users_settings: id | user_id | setting_id | setting_value_id Now before the user is added I want to patch the entity of the user with all

CakePHP 3: Multiple file uploading returns string instead of array

和自甴很熟 提交于 2019-12-12 03:37:39
问题 Hi I'm having a problem with multiple file uploading. Whenever I try to access the file properties it won't let me. I debugged my data and here's the output: Instead of returning me an array, it just returns me a string under data['files']. So I'm missing properties such as 'tmp_name', 'name', etc.. My code in my .ctp file : <?= $this->Form->create('annonce') ?> <fieldset> <legend><?= __('Publier une annonce') ?></legend> <?php echo $this->Form->input('title', ['label' => 'Titre annonce']);

Allow all actions for authentication in integration test cakephp

百般思念 提交于 2019-12-12 03:34:32
问题 I'm currently trying to write an integration test for some controller whereby it is necessary to send an authentication header. In my controller I have some actions made public accessible through the following code: namespace App\Controller\Api; use Cake\Event\Event; use Cake\Network\Exception\UnauthorizedException; use Cake\Utility\Security; use Firebase\JWT\JWT; class UsersController extends AppController { public function initialize() { parent::initialize(); $this->Auth->allow(['add',

In Cakephp 3.x, What is the Best Practice for Removing [Username] from a Plugin you install with composer?

断了今生、忘了曾经 提交于 2019-12-12 03:33:00
问题 When you install a plugin with composer, by default it puts it into ROOT/vendor/[username]/[plugin-name]. This also updates ROOT/vendor/cakephp-plugins.php with something like return [ 'plugins' => [ '[UserName]/[PluginName]' => $baseDir . '/vendor/[username]/[plugin-name]/' ] ]; This apparently also makes it so that your plugin's namespace should be something like. namespace [Username]\[PluginName]\Controller; And when you do a redirect (as an example) you refer to it with something like...

Cakephp 3.0 $query->toArray();

岁酱吖の 提交于 2019-12-12 03:13:36
问题 Hey I am trying to find a solution I am retrieving the data from mysql using this command : $meals = TableRegistry::get('Users'); $query = $meals ->find() ->select(['id' ,'username']) ->where(['role' => 'patient']); $data = $query->toArray(); This is my code after using query->toarray() I am getting this value { "id": 4, "username": "s2" } I want to put this value in my form which is like this : echo $this->Form->input('user_id', [ 'options' => [1 => 'Admin', 2 => 'Author'] ]) ; How to use

How to install a plugin manually in CakePHP 3?

纵饮孤独 提交于 2019-12-12 02:59:15
问题 I am unable to use Composer and thus have to install CakePDF plugin manually, but following examples from official CakePHP documentation does not seem to work. So here is installation flow that I have followed: 1.) Copied the plugin to app/plugins/CakePdf 2.) Updated the app's composer.json file, like following: "autoload": { "psr-4": { "CakePdf\\": "./plugins/CakePdf/src", "CakePdf\\Test\\": "./plugins/CakePdf/tests" } }, "autoload-dev": { "psr-4": { "App\\Test\\": "tests", "Cake\\Test\\": "