Commit def13a22 def13a2290adecb8e660cf59bf14395f6986f9c0 by lemon

合同文件

1 parent 6d771020
......@@ -22,9 +22,9 @@ class Treaty extends BaseModel
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function file()
public function filesNew()
{
return $this->hasMany(TreatyFile::class, 'treaty_id');
return $this->hasMany(FileMap::class, 'link_id', 'id')->where('link', 'treaty');
}
/**
......
......@@ -20,7 +20,7 @@ class MusicianAgreementService extends Service
*/
public function treatyList()
{
$res = Treaty::query()->whereIn('party_b', $this->stakeholder_ids)->where('deadline_date', '>', $this->now)->with(['file:id,treaty_id,file_id', 'file.fileInfo:id,key'])
$res = Treaty::query()->whereIn('party_b', $this->stakeholder_ids)->where('deadline_date', '>', $this->now)->with(['filesNew:id,key,link_id'])
->select(['id', 'treaty_name', 'treaty_type', 'service_type', 'deadline_date', 'music_no'])->orderByDesc('created_at')->paginate($this->pageSize);
$client = new CosHelper();
......@@ -28,9 +28,9 @@ class MusicianAgreementService extends Service
foreach ($res as &$item) {
$item_res = $item->toArray();
$files = [];
if (!empty($item_res['file'])) {
foreach ($item_res['file'] as $file_item) {
!empty($file_item['file_info']['key']) && $files[] = $file_item['file_info']['key'];
if (!empty($item_res['files_new'])) {
foreach ($item_res['files_new'] as $file_item) {
!empty($file_item['key']) && $files[] = $file_item['key'];
}
}
......