/**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function acceptCase($id)
 {
     $caseOwnerObj = CaseOwner::where("caseId", '=', $id)->where("user", '=', \Auth::user()->id)->first();
     $numberCases = CaseReport::where('user', '=', \Auth::user()->id)->get();
     if (sizeof($caseOwnerObj) > 0) {
         $caseOwnerObj->accept = 1;
         $caseOwnerObj->save();
         $caseActivity = new CaseActivity();
         $caseActivity->caseId = $id;
         $caseActivity->user = \Auth::user()->id;
         $caseActivity->addressbook = 0;
         $caseActivity->note = "Case Accepted by " . \Auth::user()->name . ' ' . \Auth::user()->surname;
         $caseActivity->save();
         $case = CaseReport::find($id);
         if ($case->status == "Pending") {
             $case->status = "Actioned";
             $case->accepted_at = \Carbon\Carbon::now('Africa/Johannesburg')->toDateTimeString();
             $case->save();
         }
         $caseOwners = CaseOwner::where("caseId", '=', $id)->where("user", "<>", \Auth::user()->id)->get();
         foreach ($caseOwners as $owner) {
             if ($owner->addressbook == 1) {
                 $user = AddressBook::find($owner->user);
             } else {
                 $user = User::find($owner->user);
             }
             $data = array('name' => $user->name, 'caseID' => $id, 'acceptedBy' => \Auth::user()->name . ' ' . \Auth::user()->surname);
             \Mail::send('emails.acceptCase', $data, function ($message) use($user) {
                 $message->from('*****@*****.**', 'Siyaleader');
                 $message->to($user->username)->subject("Siyaleader Notification - New Case Accepted: ");
             });
         }
     }
     return "ok";
 }