Slim 3 Eloquent initialization error Argument 1 must be Illuminate\Database\Capsule\Manager
<p>Disclosure: This is my first Slim app</p>
<p>I've tried to use Eloquent with Slim 3, but I can't seem to get it work. I've installed everything with composer, followed the install guide on the site.</p>
<p>When I try to use my User model (which extends the Eloquent model) I get a fatal error:</p>
<blockquote>
<p><em>Fatal error: Call to a member function connection() on null in ****\vendor\illuminate\database\Eloquent\Model.php on line 3280</em></p>
</blockquote>
<p>My appConfig looks like this:</p>
<pre><code>$config['db'] = [
    'driver'    =&gt; 'mysql',
    'host'      =&gt; '****',
    'database'  =&gt; '****',
    'username'  =&gt; '****',
    'password'  =&gt; '****',
    'charset'   =&gt; 'utf8',
    'collation' =&gt; 'utf8_unicode_ci',
    'prefix'    =&gt; '',
];
</code></pre>
<p>which I pass to the app according to the documentation:</p>
<pre><code>$app = new \Slim\App([&quot;settings&quot; =&gt; $config]);
$container = $app-&gt;getContainer();
$container['db'] = function (ContainerInterface $container) {
    $settings = $container-&gt;get('database');
    $capsule = new \Illuminate\Database\Capsule\Manager;
    $capsule-&gt;addConnection($settings);
    $capsule-&gt;setAsGlobal();
    $capsule-&gt;bootEloquent();

    return $capsule;
};
</code></pre>
<p>My User class looks like this:</p>
<pre><code>class User extends Illuminate\Database\Eloquent\Model {}
</code></pre>
<p>I've found a workaround on <a href="https://stackoverflow.com/questions/35411954/how-to-trigger-eloquent-manager-in-slim-3-1-dependency-injection">Stackoverflow</a> like so:</p>
<pre><code>use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Capsule\Manager;

    class User extends Eloquent {
            public function __construct(Manager $capsule, array $attributes = [])
        {
            parent::__construct($attributes);
        }
    }
</code></pre>
<p>But if I override the constructor according to the port I get a different error:</p>
<blockquote>
<p>_Catchable fatal error: Argument 1 passed to Up\models\User::_<em>construct() must be an instance of Illuminate\Database\Capsule\Manager, none given, called in ****\vendor\illuminate\database\Eloquent\Model.php on line 644 and defined in ****\models\User.php on line 14</em></p>
</blockquote>
<p>I'm stuck now. Please help</p>