0

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,

  • `$this->Foologs->find('all')->where($conditions)` is _not_ [**code created by bake**](https://github.com/cakephp/bake/blob/2.3.0/templates/bake/element/Controller/index.twig#L29). – ndm Mar 15 '21 at 13:17
  • yes, you are right. that is changes by me for my works. – Nite.Mug.Goo Mar 16 '21 at 07:47
  • bake wrotes `$fooLogs = $this->paginate($this->FooLogs);`. The problem is not it, why the property "FooLogs" is internally "Foologs". regards, – Nite.Mug.Goo Mar 16 '21 at 08:00
  • btw, `$this->paginate($this->FooLogs)` does not raise an exception. in this case, $this->FooLogs is null and the model identification is done by the "FooLogs" derived from the controller name. – Nite.Mug.Goo Mar 16 '21 at 08:31
  • i think "FooLogs" is the correct property name. in a hurry, i wrote `$this->loadModel('FooLogs')` in initialize () to initialize the properties. – Nite.Mug.Goo Mar 19 '21 at 06:51

1 Answers1

0

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.