只管模型的 事
class Guestinfo extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
/**
* 留言板模型
* @author apolloren
*/
// 获取器修改时间格式
public function getcreatetimeAttr($value, $data)
{
$value = $value ? $value : (isset($data['refreshtime']) ? $data['create_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public static function guestinfo()
{
$list=Guestinfo::order('id desc')->paginate(10);
return $list;
}
public static function add($username,$title,$content)
{
$user = new Guestinfo;
$user->username = $username;
$user->title = $title;
$user->content = $content;
$user->save();
// 获取自增ID
echo $user->id;
}
}