laravel的model例子

5里面直接artisan建立model

./artisan make:model MyModel

 

找到MyModel,改成下面这样

<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class MyModel extends Model {

    //添加这两个,最下面的,因为我是手工建表
    protected $table = 'app_versions';
    public $timestamps = false;
}

 

测试代码

Route::get('/', function()
{
    $data = \App\MyModel::all();
    return $data;
});

 

你可能感兴趣的:(laravel)