Welcome Guest, Not a member yet? Register   Sign In
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

(This post was last modified: 09-18-2019, 03:58 AM by InsiteFX.)

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.

Theme © iAndrew 2016 - Forum software by © MyBB