31,614 questions
0
votes
1
answer
30
views
Apache .htaccess should redirect only if substring NOT found in URI
Completely stumped fiddling with .htaccess in a CakePHP app. Checked a few SO posts and Perplexity.ai LLM. But still getting erroneous results. Trying to do a simple full host redirect, but skip the ...
0
votes
0
answers
49
views
Date field not saving on edit
My CakePHP 5 app uses a MySQL table called Documents. Each record in Documents has a 'title' and a 'dateadded' field. 'title' is TEXT type and 'dateadded' is DATE. The user can add and edit document ...
1
vote
1
answer
58
views
How avoid overwriting files in CakePHP?
I'm using CakePHP 5 and have a file upload field. This calls a function called upload in my UploadsController:
public function upload() {
$data = $this->request->getData();
$...
0
votes
0
answers
29
views
CakePHP doing incorrect date conversion
I'm building an app in CakePHP 5, and at one point it has to store and then display dates.
The date is added by the user using a standard form date control:
$this->Form->date('published');
and ...
1
vote
1
answer
31
views
Admin routes giving MissingControllerException in CakePHP
I'm building a site in CakePHP 5; I've made the main part of the site but now I'm building the admin area and getting an error.
I've set up my routes with an admin prefix, like this:
$routes->...
0
votes
1
answer
78
views
How can I find an item by id?
I'm working on a site with CakePHP 5.0. It has 2 tables: news and pages. I baked everything on the command line, and I've been able to get the pages side working ok, but I'm stumped on how to ...
0
votes
1
answer
93
views
Retrieving values from 2 tables at the same time in CakePHP 3
I'm developing a small module on CakePHP 3 and I'm currently encountering a small problem that I can't seem to solve.
I have two tables: Events and shop_ticket.
Events table:
I store information ...
1
vote
1
answer
69
views
Api Rest in CakePHP: How to return id fields (Bigint) as string and not as INT/BIGINT?
I created a REST API in CakePHP 4.5, and all the ID fields are of type Bigint. Is there a way to force CakePHP to convert these fields to strings before returning the JSON?
There are many fields, and ...
0
votes
0
answers
29
views
CakePHP Bake Error - Association alias is already set
I've just created a new site using CakePHP 5 for the first time (I've used CakePHP 2-4 before). I'm baking the models from my database, but one of them is failing.
My database tables are as follows (...
0
votes
1
answer
55
views
Resource class Administrator does not exist while implementing modeless policy
I'm trying to implement a policy for a model-less controller. The error I keep getting when I access /administrators/import
Resource class Administrator does not exist.
InvalidArgumentException
Here ...
0
votes
0
answers
77
views
Can you get CakePHP 4 to return JSON error responses automatically when writing an API?
CakePHP 4.x
We have an application which consists of a frontend web app (used by customers through a browser) and an API for some backend operations which is integrated with our other systems.
The ...
0
votes
1
answer
54
views
CakePHP 5 Middleware: Authorization check error when using custom middleware
I'm building a web application in CakePHP 5 using the Authentication and Authorization plugins.
My users can be members of multiple clubs through a many-to-many relationship (using a join table). The ...
0
votes
1
answer
38
views
Cake\ORM\Marshaller::_mergeAssociation(): Argument #1 ($original) must be of type Cake\Datasource\EntityInterface|array|null, int given
Full error:
error: [TypeError] Cake\ORM\Marshaller::_mergeAssociation(): Argument #1 ($original) must be of type Cake\Datasource\EntityInterface|array|null,
int given, called in /var/www/vhosts/dpg3....
0
votes
1
answer
82
views
File validation in CakePHP 4
Basically trying to do this https://discourse.cakephp.org/t/validate-uploaded-file-size-through-model/6755/5 in a CakePHP 4.5.9 application.
I have a Model called Whitepapers and with I'm trying to ...
0
votes
0
answers
35
views
Using `StringTemplateTrait` to build templates
I have a helper that defines the time template like this:
protected array $_defaultConfig = [
'templates' => [
` 'time' => '<time{{attrs}}><i class="far fa-clock fa-sm ...