1

I'm using ENTRUST (Laravel 5 Package). When I use command User::all(); in Php artisan tinker's Shell command line. It gives me error

PHP Fatal error: Class 'User' not found in eval()'d code on line 1

but after trying 2-3 different combination(which are wrong) if I use the same User::all();, it gives me correct result. It looks weird.

I'm new to PHP as well as Laravel.

User.php

<?php

use Zizaco\Entrust\Traits\EntrustUserTrait;

class User extends Eloquent
{
    use EntrustUserTrait; // add this trait to your user model
}

Console output:

Psy Shell v0.7.2 (PHP 5.5.9 ΓÇö cli) by Justin Hileman
>>> User::all();
PHP Fatal error:  Class 'User' not found in eval()'d code on line 1
>>> App/User::all();
PHP Fatal error:  Class 'User' not found in eval()'d code on line 1
>>> App\User::all();
PHP Fatal error:  Class 'App\User' not found in eval()'d code on line 1
>>> User::all();
=> Illuminate\Database\Eloquent\Collection {#664
     all: [
       User {#665
         id: 1,
         name: "Kartik",
         email: "******************",
         password: "qwerty",
         remember_token: null,
         created_at: "2016-08-18 17:13:40",
         updated_at: "2016-08-18 17:13:40",
       },
       User {#666
         id: 2,
         name: "Bhandari",
         email: "**************",
         password: "qwerty",
         remember_token: null,
         created_at: "2016-08-20 11:37:26",
         updated_at: "2016-08-20 11:37:26",
       },
     ],
   }
halfer
  • 19,824
  • 17
  • 99
  • 186
Kartik
  • 71
  • 1
  • 2
  • 11

1 Answers1

1

give the complete path for the modal i.e. with namespaces

project_namespace\Models\User::all()
msonowal
  • 1,553
  • 3
  • 17
  • 36