/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $caseOwners = CaseOwner::where('caseId', '=', $request['caseID'])->get(); $author = User::find($request['uid']); $caseNote = new CaseNote(); $caseNote->note = $request['caseNote']; $caseNote->user = $request['uid']; $caseNote->caseId = $request['caseID']; $caseNote->save(); $caseActivity = new CaseActivity(); $caseActivity->caseId = $request['caseID']; $caseActivity->user = $request['uid']; $caseActivity->addressbook = 0; $caseActivity->note = "New Case Noted Added by " . $author->name . " " . $author->surname; $caseActivity->save(); foreach ($caseOwners as $caseOwner) { $user = User::find($caseOwner->user); $data = array('name' => $user->name, 'caseID' => $request['caseID'], 'caseNote' => $request['caseNote'], 'author' => $author->name . ' ' . $author->surname); \Mail::send('casenotes.email', $data, function ($message) use($user) { $message->from('*****@*****.**', 'Siyaleader'); $message->to($user->username)->subject("Siyaleader Notification - New Case Note: "); }); } return "ok"; }
$precinctObj = Municipality::find($case->precinct); $Precinct = $precinctObj->name; $Submitted = $case->created_at; $Status = $case->status; $catObjCat = Category::find($case->category); $Category = $catObjCat->name; \Log::info($Category); $PhotoURL = "http://41.216.130.6:8080/siyaleader-dbnports-mobileApp-api/port_backend/public/" . $case->img_url; $LastActivity = $case->updated_at; $Reporter = $ReporterName; $Position = $ReporterPosition; $Mobile = $ReporterMobile; $Priority = $case->priority; $Description = $case->description; if ($case->id) { $noteResult = CaseNote::where('caseId', '=', $case->id)->first(); } if (sizeof($noteResult) > 0) { $noteUserObj = User::find($noteResult->user); $AuthDate = $noteResult->created_at; $Author = $noteUserObj->name . ' ' . $noteUserObj->surname; $Note = $noteResult->note; } else { $AuthDate = ""; $Author = ""; $Note = ""; } $imageStatus = ""; $catStatus = ""; if ($Status == "Pending") { $catStatus = "Pen";