0

Cake Bake generated the following code snipped:

public function index()
{
$this->paginate = [
        'contain' => ['Users']
    ];

    $shops = $this->paginate($this->Shops);

    $this->set(compact('shops'));
}

The result is the error message: syntax error, unexpected 'use' (T_USE)

When I change the code to this it works:

public function index()
{
    $this->paginate = [
        'contain' => ['Users']
    ];

    // $shops = $this->paginate($this->Shops);
    $this->loadComponent('Paginator');
    $shops = $this->Paginator->paginate($this->Shops->find());

    $this->set(compact('shops'));
}

I find this strange in particular because the first code version is generated by cake bake and supposed to work straight away, isnt it?

elMeroMero
  • 752
  • 6
  • 18
  • 5
    There's no such syntax error in that code snippet, so the problem is somewhere else. Whenever receiving errors, please always post **the complete error**, that is, including **the full stacktrace** (ideally copied from the logs where it is available in a properly readable fashion) - thanks! – ndm Jun 03 '18 at 09:19
  • You are right the problem must have been caused by me. What I did to solve was to regenerate the code by baking again and then it worked. I will post whole error report next time. Thanks for the advice. – elMeroMero Jun 04 '18 at 20:03
  • What am i supposed to do now to adhere to stack policy? Delete the question? – elMeroMero Jun 04 '18 at 20:04

0 Answers0