|
|
@@ -6,6 +6,7 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
use App\Models\Channel;
|
|
|
use App\Models\Article;
|
|
|
use App\Models\Collection;
|
|
|
+use App\Models\Project;
|
|
|
use App\Http\Api\StudioApi;
|
|
|
use App\Http\Api\GroupApi;
|
|
|
use App\Http\Api\UserApi;
|
|
|
@@ -21,32 +22,32 @@ class ShareResource extends JsonResource
|
|
|
public function toArray($request)
|
|
|
{
|
|
|
//获取资源信息
|
|
|
- $res_name="";
|
|
|
- $owner="";
|
|
|
+ $res_name = "";
|
|
|
+ $owner = "";
|
|
|
switch ($this->res_type) {
|
|
|
case 1:
|
|
|
# PCS 文档
|
|
|
break;
|
|
|
case 2:
|
|
|
# Channel 版本
|
|
|
- $res = Channel::where('uid',$this->res_id)->first();
|
|
|
- if($res){
|
|
|
+ $res = Channel::where('uid', $this->res_id)->first();
|
|
|
+ if ($res) {
|
|
|
$res_name = $res->name;
|
|
|
$owner = StudioApi::getById($res->owner_uid);
|
|
|
}
|
|
|
break;
|
|
|
case 3:
|
|
|
# Article 文章
|
|
|
- $res = Article::where('uid',$this->res_id)->first();
|
|
|
- if($res){
|
|
|
+ $res = Article::where('uid', $this->res_id)->first();
|
|
|
+ if ($res) {
|
|
|
$res_name = $res->title;
|
|
|
$owner = StudioApi::getById($res->owner);
|
|
|
}
|
|
|
break;
|
|
|
case 4:
|
|
|
# Collection 文集
|
|
|
- $res = Collection::where('uid',$this->res_id)->first();
|
|
|
- if($res){
|
|
|
+ $res = Collection::where('uid', $this->res_id)->first();
|
|
|
+ if ($res) {
|
|
|
$res_name = $res->title;
|
|
|
$owner = StudioApi::getById($res->owner);
|
|
|
}
|
|
|
@@ -54,20 +55,27 @@ class ShareResource extends JsonResource
|
|
|
case 5:
|
|
|
# 版本片段 不支持
|
|
|
break;
|
|
|
+ case 6: //workflow
|
|
|
+ $res = Project::where('uid', $this->res_id)->first();
|
|
|
+ if ($res) {
|
|
|
+ $res_name = $res->title;
|
|
|
+ $owner = StudioApi::getById($res->owner_id);
|
|
|
+ }
|
|
|
+ break;
|
|
|
default:
|
|
|
# code...
|
|
|
break;
|
|
|
}
|
|
|
$data = [
|
|
|
- "id"=>$this->id,
|
|
|
- "res_id"=> $this->res_id,
|
|
|
- "res_type"=> $this->res_type,
|
|
|
- "collaborator_type"=> $this->cooperator_type,
|
|
|
- "power"=> $this->power,
|
|
|
- 'res_name'=>$res_name,
|
|
|
- 'owner'=>$owner,
|
|
|
- "created_at"=> $this->created_at,
|
|
|
- "updated_at"=> $this->updated_at,
|
|
|
+ "id" => $this->id,
|
|
|
+ "res_id" => $this->res_id,
|
|
|
+ "res_type" => $this->res_type,
|
|
|
+ "collaborator_type" => $this->cooperator_type,
|
|
|
+ "power" => $this->power,
|
|
|
+ 'res_name' => $res_name,
|
|
|
+ 'owner' => $owner,
|
|
|
+ "created_at" => $this->created_at,
|
|
|
+ "updated_at" => $this->updated_at,
|
|
|
];
|
|
|
switch ($this->cooperator_type) {
|
|
|
case 0:
|
|
|
@@ -78,7 +86,7 @@ class ShareResource extends JsonResource
|
|
|
# code...
|
|
|
$data['group'] = GroupApi::getById($this->cooperator_id);
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
return $data;
|
|
|
}
|
|
|
}
|