Thursday, March 16, 2017

Class ' not found in laravel 5.0.16

I am beginner in laravel. And i am using laravel 5.0.16 in my wamp server.I have been learning laravel by free video tutorial available in laracasts.com.I have been trying to fetch data from database.i have checked that my app is already connected to database.

i do have below structure in app folder:

-app
   -Http(folder)
   -Other folders (folder)
   -Article.php (file)
   -User.php (file)

In side Http folder:

   -Controllers (folder)
   -Middleware (folder)
   -Requests (folder)
   -Kernel.php (file)
   -routes.php (file)

In Controllers folder:

   -ArticleController.php (file)

Below is code in side routes,Controllers and model file:

/*routes*/

  Route::get('articles','ArticleController@index');

/*Controller file*/
use App\models\Article;
namespace App\Http\Controllers;
use App\Http\Request;
use App\Http\Controllers\Controller;
class ArticleController extends Controller {
  public function index()
  {
    $users = Article::all();
    return $users;
   }
}

/*Model file - Article.php*/
namespace App\models;
use Illuminate\Database\Eloquent\Model;
class Article extends Model {
 protected $table = 'users';
 protected $fillable = ['id','firstname', 'lastname',   'email','reg_date'];
}

Where users is DB table with fields.

I am getting below arror: FatalErrorException in ArticleController.php line: Class 'App\Http\Controllers\Article' not found

I have check other SO forums but they didn't help me, can anyone suggest me what am i missing?



via Ash Patel

Advertisement