Questions tagged [cakephp-3.x]

Questions about 3.x branch of the CakePHP MVC framework. Use this tag in combination with the general [cakephp] tag. If your question applies to CakePHP more generally, use only the [cakephp] tag.

963 questions
5
votes
2 answers

cakephp 3 url in controller

I have to send url from controller to view with json..It not ok when i use $this->Html->link or $this->Url->build for link. How can i send link to json.. use Cake\View\Helper\UrlHelper; at top foreach($schedules as $s) : …
Ye Htun Z
  • 2,079
  • 4
  • 20
  • 31
5
votes
1 answer

CakePHP 3: Changing structure of result set

I'm new to CakePHP and have the following problem: I have the tables "Images", "Keywords" and "KeywordCategories". Every image can have many keywords (many to many) and every keyword has a category (many to one). Retrieving a list of images…
chrisch
  • 189
  • 9
4
votes
1 answer

How to set visible length for type tinyint,smallint while alter column using phinx migration in cakephp3?

I tried the following code to migrate a field "exp" to datatype tinyint(2), i want to make visible-length 2 with datatype tinyint. $table->changeColumn('exp', 'integer', [ 'limit' => MysqlAdapter::INT_TINY, //is there any option to set…
D Coder
  • 331
  • 2
  • 10
4
votes
1 answer

select count of records group by month in cakephp 3

I'm using CakePHP 3.x+ I have to show a graph on the page and thus want to build script for that. I have to select count of records group by month for current year. This is what I have tried. $graph = $this->GenerateVideos->find() …
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
4
votes
3 answers

Cakephp 3 search query, with concat

I'm trying to perform a search on two joined columns, fname and lname. This does not appear to be working: Object of class Cake\Database\Expression\FunctionExpression could not be converted to string $users =…
toast
  • 1,860
  • 2
  • 26
  • 49
4
votes
1 answer

How to get sum of total counts with most recent hourly / daily / weekly / yearly interval in cakephp 3?

I've a table as following- Now I need to make report of total number of counts in every hour, week, month and year. It may have sum 0 but should be include on the result. For example I need the result as follows- $hourlyResult = array( '00:01' =>…
biplob
  • 1,252
  • 1
  • 11
  • 29
4
votes
1 answer

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

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…
pmelon
  • 187
  • 2
  • 11
4
votes
2 answers

Sort query results by nested association in cakephp 3

The Problem: I have a cakephp 3.x query object with two nested associations, Organizations.Positions.Skills, that is being set to a view variable, $Organizations. I'm trying to sort the query's resulting top level array by a column in the first…
Mira915
  • 43
  • 1
  • 5
4
votes
1 answer

CakePHP 3.x: how to implement event listener in plugin / plugins src-directory doesn't get loaded

In order to build an extendable blogging system with CakePHP I’d like to realize something like extension hooks in Wordpress. My plan is to have a base SQL to load the articles in the main application. This SQL should be possible to extend by a…
F.C.Kawé
  • 61
  • 4
4
votes
2 answers

Load vendor assets from custom directory - cakephp 3

I want to create vendor package in cakephp 3. It should depend on another package, that has both php files and some static assets: like js, css, img etc. Setting up php files autoloading I am able to handle. However to load static files from another…
dav
  • 8,931
  • 15
  • 76
  • 140
4
votes
1 answer

How to get only selected fields from contain in cakephp3

I have a query as below but I need only certain fields not all the fields. I have set the autoFields to false but the query still returns all the fields. $tenancies = $this ->find('all') ->autoFields(false) ->select([ …
Fury
  • 4,643
  • 5
  • 50
  • 80
4
votes
1 answer

Migration CakePHP 2 to 3: Before/after-attribute of save button (form helper)

Migrating CakePHP 2.x to 3.x, in submit button CakePHP 2.x have after and before attribute, but that is not working on CakePHP 3.x. Form->submit(__('Save'), array( 'div' => 'form-actions', 'class' => 'btn btn-large…
sree s
  • 61
  • 2
4
votes
2 answers

Use one date format in whole project of cakephp 3.x

This might be a simple question. Is there any way that I can set in my project just a single date format and have this date format everywhere. And by everywhere I mean the view, edit, index actions. The format I need to have is Y-m-d H:i:s and it…
gmponos
  • 2,157
  • 4
  • 22
  • 33
4
votes
3 answers

Check if object exists or is empty in view template

How do you check within the view template if the result object contains any entries? (There was a similar question already, but this one is slightly different) Take the CakePHP 3 blog tutorial for example. They show how to list all articles on one…
Oops D'oh
  • 941
  • 1
  • 15
  • 34
3
votes
1 answer

How to test exceptions when using CakePHP's integration test case?

I'm trying to test my CakePHP 3 Internal error Exception. My Controller: public function getConfirmation() { if (!$this->request->getData()) throw new InternalErrorException(__('data not found')); $confirmStatus =…
1
2
3
64 65