1.创建模型Eloquent ORM

php artisan make:model Flight

创建实例如下:

<?php

namespace App\Http\Model\Login;

use Illuminate\Database\Eloquent\Model;

class Admin extends Model
{
    // protected $table = "users";  //自定义表名
    // protected $primaryKey = "ID"; //设置主键
    // public $timestamps = false;   //禁用 数据表自动更新字段

    /**
     * The attributes that are mass assignable.
     * 可以修改分配的属性
     * @var array
     */
    protected $fillable = [
        'name', 'level', 'password', 'btStatus'
    ];

    /**
     * The attributes that should be hidden for arrays.
     * 需要隐藏属性的列
     * @var array
     */
    protected $hidden = [
        'password',
    ];
}
    /**
     * 表明模型是否应该被打上时间戳
     *
     * @var bool
     */
    public $timestamps = false;

 

更多相关资料查阅:https://xueyuanjun.com/post/19974

 

posted on 2020-03-21 16:39  siegel  阅读(246)  评论(0编辑  收藏  举报