在app目录下创建了Articles.php
模型文件,然后在控制器中调用时报错。错入如下:
Class 'App\Http\Controllers\Articles' not found
控制器中的代码如下:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class ArticlesController extends Controller
{
/**
* [index 文章首页]
* @return [type] [description]
*/
public function index()
{
$articles = Articles::all();
return $articles;
return view('articles.index');
}
}
模型层的代码如下:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Articles extends Model
{
//
}