The property name of the controller does not match the one specified by bake (CakePHP4)

54 views Asked by At

i have created a table named "foo_logs" by bake migrations. and then, created model and controller named "FooLogs" by bake.

Now, the model and controller have been created. The controller has a property called "$FooLogs" (bake wrote).

i tried to get the data for "foo_logs" but I see "Call to a member function find () on null". as follows;

$fooLogs = $this->paginate($this->FooLogs->find('all')->where($conditions));

i searched for the reason why $ this-> FooLogs is null. then, when identifying the modelClass, i confirmed that "Foologs" was used (l instead of L).

i want to know why "Foologs" is used. bakes it was completed as "FooLogs"! maybe the word "log" has a special meaning in CakePHP?

thanks in advance. reguards,

1

There are 1 answers

0
Nite.Mug.Goo On

The cause is the link output to the page of the controller, as follows. It was because the controller name was "foologs" as follows:

$this->Html->link('xxxxx', ['controller' => 'foologs'])

When resolving a model class, only the first letter seems to be capitalized (foologs → Foologs).

It's an ordinary mistake. I confirmed that it works without any problem by writing the controller name correctly.

I apologize to you for a fuss over.