first commit
This commit is contained in:
44
application/common/model/Direct.php
Normal file
44
application/common/model/Direct.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\common\model;
|
||||
|
||||
class Direct extends _Init
|
||||
{
|
||||
/**
|
||||
* 模型初始化【事件注册】
|
||||
*/
|
||||
protected static function init()
|
||||
{
|
||||
self::beforeInsert(function ($data) {
|
||||
$data->status = 1;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取封面地址
|
||||
* @param [type] $value 封面id
|
||||
* @param [type] $data 文章数据
|
||||
* @return [type] 图片地址
|
||||
*/
|
||||
public function getCoverAttr($value, $data)
|
||||
{
|
||||
return Storage::where('id', $data['storage_id'])->value('path');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取音/视频地址
|
||||
* @param [type] $value 封面id
|
||||
* @param [type] $data 文章数据
|
||||
* @return [type] 图片地址
|
||||
*/
|
||||
public function getExtPathAttr($value, $data)
|
||||
{
|
||||
return Storage::where('id', $data['ext_id'])->value('path');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user