5里面直接artisan建立model
./artisan make:model MyModel
找到MyModel,改成下面这样
<?php namespace App; use IlluminateDatabaseEloquentModel; class MyModel extends Model { //添加这两个,最下面的,因为我是手工建表 protected $table = 'app_versions'; public $timestamps = false; }
测试代码
Route::get('/', function() { $data = AppMyModel::all(); return $data; });