title: call to a member function connection() on null laravel
body: <p>Im testing out something in laravel but the code below gives me error and I couldnt figure out whats the problem</p>
  
  <p>Code :</p>
  
  <pre><code>    &lt;?php
  require __DIR__.'/../bootstrap/autoload.php';
  $app = require_once __DIR__.'/../bootstrap/app.php';
  $posts = \App\Models\Post::take(5)-&gt;get()-&gt;toArray();
  file_put_contents('1.txt', print_r($posts, 1));
  &gt;
  </code></pre>
  
  <p>error :</p>
  
  <pre><code>Fatal error: Uncaught Error: Call to a member function connection() on null in /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:3351 Stack trace: #0 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3317): Illuminate\Database\Eloquent\Model::resolveConnection(NULL) #1 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1861): Illuminate\Database\Eloquent\Model-&gt;getConnection() #2 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1834): Illuminate\Database\Eloquent\Model-&gt;newBaseQueryBuilder() #3 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1804): Illuminate\Database\Eloquent\Model-&gt;newQueryWithoutScopes() #4 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3561): Illuminate\Database\Eloquent\Model-&gt;newQuery() #5 /home/vowave/public_html/vendor/laravel/framework/sr in /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 3351
  </code></pre>