|
@@ -511,12 +511,17 @@ class CircleMessageRepository
|
|
|
DB::beginTransaction();
|
|
|
try {
|
|
|
$imgData = [];
|
|
|
- foreach ($imgs as $img) {
|
|
|
+ foreach ($imgs as $k=>$img) {
|
|
|
+ $isMain = 0;
|
|
|
+ if($k==0){
|
|
|
+ $isMain=1;
|
|
|
+ }
|
|
|
$imgData[] = [
|
|
|
'circle_id' => $request['circle_id'],
|
|
|
'uid' => $userInfo['uid'],
|
|
|
'image' => $img,
|
|
|
'patch_num' => $patchNum,
|
|
|
+ 'is_main' => $isMain,
|
|
|
'created_at' => $date,
|
|
|
'updated_at' => $date
|
|
|
];
|
|
@@ -541,11 +546,10 @@ class CircleMessageRepository
|
|
|
{
|
|
|
$perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
|
$where[] = ['circle_id', $request['circle_id']];
|
|
|
+ $where[] = ['is_main', 1];
|
|
|
|
|
|
return $this->interestCirclePicture
|
|
|
- ->select('interest_circle_pictures.*','count(patch_num)')
|
|
|
->where($where)
|
|
|
- ->groupby('patch_num')
|
|
|
->orderBy('id', 'desc')
|
|
|
->paginate($perPage);
|
|
|
}
|
|
@@ -555,7 +559,7 @@ class CircleMessageRepository
|
|
|
*/
|
|
|
public function deletePicture($request)
|
|
|
{
|
|
|
- $circle = $this->interestCirclePicture->where('id', $request['id'])->first();
|
|
|
+ $circle = $this->interestCirclePicture->where('patch_num', $request['id'])->first();
|
|
|
if (!$circle) {
|
|
|
return jsonError('相册不存在');
|
|
|
}
|
|
@@ -570,7 +574,7 @@ class CircleMessageRepository
|
|
|
}
|
|
|
DB::beginTransaction();
|
|
|
try {
|
|
|
- $circle->delete();
|
|
|
+ $this->interestCirclePicture->where('patch_num', $request['id'])->delete();
|
|
|
DB::commit();
|
|
|
return jsonSuccess();
|
|
|
|