Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/Http/Controllers/ClockInOutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,28 @@ public function clockOut(Request $request) {
return redirect()->back()->with('message', ['success', "You have clocked out with $hours hour$hours_label_suffix and $minutes minute$minutes_label_suffix on the clock. Good work!"]);
}

/**
* Get recent notes
*
* Retrieves the 'history' (20 most recent notes) and 'latest' note (even if blank, "").
*
* @param int $subcategory_id
* @return \Illuminate\Http\JsonResponse
*/
public function getRecentNotes($subcategory_id)
{
$raw = TempLog::where('user_id', auth()->user()->id)
->where('subcategory_id', $subcategory_id)
->orderBy('created_at', 'desc')
->take(20)
->pluck('notes');

return response()->json([
'latest' => $raw->first(),
'history' => $raw->filter(fn($n) => !empty(trim($n)))->unique()->values()
]);
Comment on lines +254 to +263

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be an issue. We don't actually need 20 and the null issue can't actually happen.

}

// Cancel clock in
public function cancelClockIn() {
// Check to see if they are already clocked out.
Expand Down
Loading