init: 项目初始代码
This commit is contained in:
44
app/api/model/ImagesFile.php
Normal file
44
app/api/model/ImagesFile.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace app\api\model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ImagesFile extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 上传用户昵称关联
|
||||
*/
|
||||
public function uploader()
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'up_id')->bind(['uploader_name'=>'nickname']);
|
||||
}
|
||||
|
||||
// 根据ID查询
|
||||
public function scopeId($query, $id)
|
||||
{
|
||||
if (is_array($id)) {
|
||||
$query->where('id', 'in', $id);
|
||||
} else {
|
||||
$query->where('id', '=', $id);
|
||||
}
|
||||
}
|
||||
|
||||
// 根据上传人查询
|
||||
public function scopeUpId($query, $up_id)
|
||||
{
|
||||
$query->where('up_id', '=', $up_id);
|
||||
}
|
||||
|
||||
// 根据文件MD5值查询
|
||||
public function scopeFileMd5($query, $md5)
|
||||
{
|
||||
$query->where('file_md5', '=', $md5);
|
||||
}
|
||||
|
||||
// 根据文件hash值查询
|
||||
public function scopeFileHash($query, $hash)
|
||||
{
|
||||
$query->where('file_hash', '=', $hash);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user