cakephp-3.2

Sort by name in alphabetical order not working in data table

天大地大妈咪最大 提交于 2021-01-27 13:37:35
问题 Here i have fetched the data from controller , all are coming fine (according to the alphabetical order) ,but in data table its not coming what i want to get ,means in alphabetical order while viewing . Here all the data in descending order by default aaSorting: [[0, "desc"]], I need it to be sort according to the name field in alphabetical order I have attached a snap for more clarification. Here i want all the center name should be in alphabetical order. Please suggest me. 回答1: <script> $

how to access parameters from url in cakephp 3

混江龙づ霸主 提交于 2020-07-03 08:53:30
问题 In cook book of cakephp 3. It is given to build url using echo $this->Url->build([ "controller" => "Posts", "action" => "view", "foo" => "bar" ]); which will output as /posts/view/foo:bar How to access the foo:bar in action and save in a variable $foo ? 回答1: there's an error in the cookbook, so I opened this ticket if you use this code echo $this->Url->build([ "controller" => "Posts", "action" => "view", "foo" => "bar" ]); you'll get an url like this /posts/view/?foo=bar the manual here

how to access parameters from url in cakephp 3

允我心安 提交于 2020-07-03 08:52:06
问题 In cook book of cakephp 3. It is given to build url using echo $this->Url->build([ "controller" => "Posts", "action" => "view", "foo" => "bar" ]); which will output as /posts/view/foo:bar How to access the foo:bar in action and save in a variable $foo ? 回答1: there's an error in the cookbook, so I opened this ticket if you use this code echo $this->Url->build([ "controller" => "Posts", "action" => "view", "foo" => "bar" ]); you'll get an url like this /posts/view/?foo=bar the manual here

Cakephp 3 - Auth session cannot destroy

允我心安 提交于 2019-12-25 09:15:41
问题 I use Cakephp 3.2.11 on Cloud 9 IDE server. When I logged out to my app via Auth component. I didn't log in again but I tried to access some pages. It was appeared Auth session login request like: (I didn't design it) I type username & password in my Users table in database. It was LOGGED IN. Now when I tried log out, destroy all session; my app still recorded the session what I logged in as above. I use debug to check: debug($this->request->session()->read('Auth')); Here my logout() public

PHPExcel unable to read file

◇◆丶佛笑我妖孽 提交于 2019-12-25 07:59:40
问题 I'm using CakePHP 3.2 and PHPExcel library to import data from excel sheet to database. I have the library at /vendor/PHPExcel/Classes/PHPExcel.php /vendor/PHPExcel/Classes/PHPExcel/IOFactory.php and the action in controller is public function bulkUpload() { $inputFileName = $this->request->data('excel_data'); //debug($inputFileName['name']); if ($inputFileName != '') { $inputFileType = \PHPExcel_IOFactory::identify($inputFileName); $objReader = \PHPExcel_IOFactory::createReader(

Linking same table with two foreign keys in cakephp 3

痞子三分冷 提交于 2019-12-23 21:16:34
问题 I have a table match_schedules which stores matches between two teams . There is table teams to store team information. Columns of match_schedules are +-----+---------+---------+-------+-------+ | id | team_a | team_b | date | venue | +-----+---------+---------+-------+-------+ Since I have two columns team_a and team_b referencing teams table, I can't use team_id as foreign key in both columns. Now, I want to associate these two columns with teams table so that I can easily retrieve

Show custom field in query list in cakephp3

守給你的承諾、 提交于 2019-12-23 02:17:49
问题 I want to create a dropdown with custom field but my list query append id field into the query. How to show only selected fields in my query. $this->loadModel('CardTypes'); $cardTypes = $this->CardTypes->find('list')->select(['code', 'name']); In my view $this->Form->select('card_type_id', $cardTypes, [ 'default' => 'DELTA']); 回答1: see the manual $cardTypes = $this->CardTypes->->find('list', [ 'keyField' => 'code', 'valueField' => 'name' ]); 来源: https://stackoverflow.com/questions/38831063

Find by conditions on associated model in CakePHP 3

烂漫一生 提交于 2019-12-21 19:59:15
问题 I have two tables orders and sub_orders . Their association is $orders->hasMany('SubOrders', [ 'foreignKey' => 'order_id' ]); Both tables have invoice_no and sub_invoice columns in orders and sub_orders respectively. I have to find records from orders table containing associated sub_orders where $trackingId will match either Orders.invoice_no or SubOrders.sub_invoice $findOrder = $this->Orders->find('all', [ 'conditions' => [ 'OR' => [ 'Orders.invoice_no' => $trackingId, 'SubOrders.sub

Query builder fetch data in cakephp 3.2

最后都变了- 提交于 2019-12-12 03:44:55
问题 I am using this below code to sum up all my wallet balance . $query = $this->Wallets->find(); $query->select([ 'count' => $query->func()->count('id'), 'total_price' => $query->func()->sum('amount') ]) ->where(['status' => 4, 'user_id' => $user_id]); pj($query); echo $query->total_price; exit; out put of pj($query); [ { "count": 2, "total_price": 700 } ] Here i have tried to get single individual value using below query echo $query->total_price; I am not getting it. What is the proper syntax

CakePHP 3 : Trying to get property of non-object

点点圈 提交于 2019-12-12 03:37:15
问题 I'm working on CakePHP 3.2 and in login() action, want to allow login to only those whose status is verified = 1 public function login() { if ($this->request->is('post') || $this->request->query('provider')) { $user = $this->Auth->identify(); if ($user) { if ($user->verified != 1) { // LINE 6 $this->Flash->error(__('You have not yet verified your account. Please check your email to verify your account before login'), [ 'params' => [ 'userId' => $user->id, // LINE 9 ], ['escape' => false] ]);