private function __kickMember($club, $member)
 {
     DB::transaction(function () use($club, $member) {
         try {
             $club->managers()->detach($member);
             $club->members()->detach($member);
             $join_audit = JoinAudit::where('club_id', $club->id)->where('user_id', $member)->first();
             $join_audit->delete();
         } catch (\Exception $e) {
             throw $e;
         }
     });
 }
Example #2
0
 private function disapproveJoin($join_id, $reason)
 {
     $join_requests = JoinAudit::findOrFail($join_id);
     try {
         DB::transaction(function () use($join_requests, $reason) {
             $join_requests->status = 2;
             $join_requests->reject_reason = $reason;
             $join_requests->save();
         });
     } catch (\Exception $e) {
         throw $e;
     }
     return True;
 }
Example #3
0
 public function submitJoin(Request $requests, $club)
 {
     $user = Auth::user();
     $club = Club::findOrFail($club);
     $relation = JoinAudit::where('user_id', $user->id)->where('club_id', $club)->first();
     if (!($relation === null) and $relation->status != 2) {
         return "你已经提交过申请啦";
     }
     $input = $requests->all();
     $input['nickname'] = $user->nickname;
     $join_requests = new JoinAudit($input);
     try {
         \DB::transaction(function () use($user, $club, $join_requests) {
             $user->unauditedJoin()->save($join_requests);
             $club->unauditedJoin()->save($join_requests);
         });
     } catch (\Exception $e) {
         throw $e;
     }
     return "Join requests submitted";
 }