first commit
This commit is contained in:
34
application/common/model/Advert.php
Normal file
34
application/common/model/Advert.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\common\model;
|
||||
|
||||
class Advert extends _Init
|
||||
{
|
||||
/**
|
||||
* 模型初始化【事件注册】
|
||||
*/
|
||||
protected static function init()
|
||||
{
|
||||
self::beforeUpdate(function ($data) {
|
||||
$data->update_time = time();
|
||||
});
|
||||
|
||||
self::beforeInsert(function ($data) {
|
||||
$data->create_time = time();
|
||||
$data->update_time = 0;
|
||||
$data->status = 1;
|
||||
});
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
return $this->hasMany('AdvertDetail')->where('status', '>=', 0);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user