• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Undefined variable: config in Model

I use code in Model:
PHP Code:
$encrypter = \Config\Services::encrypter($config); 
And I have error: "Undefined variable: config". When I use this code in controller - it works. Explain please reason of error.e: con

It's telling you that your $config variable is not defined.

PHP Code:
public $config ''

So to fix you need to define $config in your code.

Then you code would look like this

PHP Code:
$encrypter = \Config\Services::encrypter($this->config); 

Unless this is in a method then you would just assign a value to $config.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Why does code works without declaration of variable $config into Controller, but it doesn't work into Model? I don't search decision. I need explanation.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.