Questions about 4.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.
Questions tagged [cakephp-4.x]
511 questions
1
vote
0 answers
How to implement CakePHP ACL plugin using Authentication plugin
I've been working on a project and the first thing I did was adding the Authentication and Authorization plugins. I did not used AuthComponent at all since its deprecated.
Now I want to add extra logic on the database and installed the ACL Plugin. I…

pkdpqowjodiv
- 123
- 1
- 7
1
vote
1 answer
CakePHP chain custom finder with OR condition
How to chain custom finders with OR condition?
I have a beforeFind() method where I check permissions.
if (isset($access->corporate)) {
$query->find('forCorporate', ['corporate_id' => $access->corporate]);
}
if (isset($access->company)) {
…

rrd
- 1,441
- 2
- 15
- 36
1
vote
0 answers
Can't load Model to save data in WebSocketController.php (use Ratchet)
I use Ratchet to build Realtime for Project Cakephp. I can sent message to clients but I can't save message to database. When I use loadModel to start save data, it has error.
Class:
namespace App\Controller;
use Ratchet\ConnectionInterface;
use…

Anh Lee
- 11
- 1
1
vote
0 answers
How to properly check the ACL using the authorization plugin in CakePHP 4?
I am currently using CakePHP 4 with the following plugins installed:
cakephp/acl CakePHP ACL plugin
cakephp/authorization CakePHP authorization plugin
Before, we used the AuthComponent with the ACL plugin to check for authorization.
Now, the…

kgbph
- 841
- 1
- 8
- 26
1
vote
1 answer
Cakepdf not showing image for DomPdf
I am using cakepdf plugin to generate pdf in cakephp application.
I am using below configuration for dompdf
Configure::write('CakePdf', [
// 'engine' => 'CakePdf.WkHtmlToPdf',
'engine' => 'CakePdf.DomPdf',
…

Niloy Rony
- 602
- 1
- 8
- 23
1
vote
1 answer
CakePHP 4 How can I display month input field as a number?
In cakephp 3.x I have used monthNames attribute for months displayed as numbers by passing false. Like below example.
echo $this->Form->month('mob', ['monthNames' => false]);
In version 4.x , This example code has remove from…

Niloy Rony
- 602
- 1
- 8
- 23
1
vote
0 answers
How to fetch associate data with group by only one column?
I have three tables in the postgres.
ChatMessages
ChatReactions
ChatReactionTypes
The association looks like this :
I am trying to get the user reaction list message wise. Like this example. This modal is opened per message wise :
I have tried…

Sabbir Ahmed
- 23
- 7
1
vote
1 answer
How to get data by associative order?
I have two tables.
chat_rooms
chat_pinned_rooms
chat_rooms has has_many relation with chat_pinned_rooms by chat_room_id.
Now I want to sort (order) chat_rooms data by chat_pinned_rooms.
I have tried below queries :
$this->ChatRooms->find()
…

Sabbir Ahmed
- 23
- 7
1
vote
0 answers
CakePHP 4.2: Download link from Gmail does not work
Our CakePHP 4 web app sends email to clients with a link for direct download. When the client clicks on the link, the download of the document starts.
This works great if the user receives the mail in their email client, or clicks on the download…

Salines
- 5,674
- 3
- 25
- 50
1
vote
1 answer
How to query data that is associated with a specific join table entry?
I have 2 tables with has many relationship: Users and Tests, an the join table generated with bake that associates both TestsUsers.
In TestsUsers, I have 2 extra fields (besides user_id and test_id) named score and date. For adding a record for the…
1
vote
2 answers
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Users.email' in 'where clause'
i'm working in cakephp 4 . i have set the model ('Representatives') for login authentication but it is using another model with name users for authentication. i have uploaded the AppController.php file as well as EmployeesController.php file where…

Kunal Khichi
- 35
- 7
1
vote
1 answer
how can i redirect user to the user page and admin to the admin page in cakephp
Whenever i logged in i have redirected all to 'welcome.php'. But if i want user to redirect on user page and admin to redirect on admin page. what can I do. ? i have defined types of users already just want to redirect them separately. for eg. user…

Kunal Khichi
- 35
- 7
1
vote
0 answers
CakePHP 4.x : How to create a set of form controls that list all of the values in a HABTM (through) association?
I'm trying to create single edit form based on contacts that allows me to update/add skill levels for all the skills even if the contact doesn't already have a rating.
Something like:
Edit Contact
Name [TextBox: John Doe]
Skills
C# …

Michael Coury
- 191
- 1
- 8
1
vote
1 answer
Custom functions for non-select queries Cake Query Builder
I would like to use the mariadb INET_ATON() on an insert query with Cakephp Query Builder.
INSERT INTO failed_logins
SET email = 'example@test.com', ip_address = INET_ATON('192.168.0.1'), sent_email = 1;
Then I'd like to retrieve the data with…

Samuel Gfeller
- 840
- 9
- 19
1
vote
1 answer
How to load multiple models for whole controller in CakePHP 4
In cakephp 2.x we can load multiple models for whole controller

Yogesh Saroya
- 1,401
- 5
- 23
- 52