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); } }