mercredi 29 août 2018

How to access database outside the APP directory

I have a php file that contain in my Laravel public folder called login.php. I want to get all use data from my mySql database.

require_once __DIR__.'/../vendor/autoload.php';
$app = require __DIR__ . '../../bootstrap/app.php';
$app->boot();
$user=new \App\User();
dd(user::all());//get all user details.

When I run this, It return an error message:

Fatal error: Uncaught Error: Call to a member function connection() on null in C:\inetpub\wwwroot\blog2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1138 Stack trace: #0 C:\inetpub\wwwroot\blog2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1104): Illuminate\Database\Eloquent\Model::resolveConnection(NULL) #1 C:\inetpub\wwwroot\blog2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(936): Illuminate\Database\Eloquent\Model->getConnection() #2 C:\inetpub\wwwroot\blog2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(847): Illuminate\Database\Eloquent\Model->newBaseQueryBuilder() #3 C:\inetpub\wwwroot\blog2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(885): Illuminate\Database\Eloquent\Model->newModelQuery() #4 C:\inetpub\wwwroot\blog2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(836): Illuminate\Database\Eloquent\Model->newQueryWithoutScopes() #5 C:\inetpub\wwwroot\blog2\vendor\laravel\framework\s in C:\inetpub\wwwroot\blog2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 1138

How can I get all user data here.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2wm94pM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire