where('friend_id', $friend_id)->orderBy('id', 'desc')->first(); if ($result && $result->status == 0) { $result->remarks = $remark; $result->updated_at = date('Y-m-d H:i:s'); $result->save(); return true; } $result = UsersFriendsApply::create([ 'user_id' => $user_id, 'friend_id' => $friend_id, 'status' => 0, 'remarks' => $remark, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s') ]); return (bool)$result; } /** * 同意好友申请 */ public function accept() { } /** * 拒绝好友申请 */ public function decline() { } }