2017-12-29 17:19:27 +01:00
|
|
|
<?php
|
2018-01-14 18:09:34 +01:00
|
|
|
|
2018-09-25 17:33:31 +02:00
|
|
|
use Carbon\Carbon;
|
2020-09-12 19:45:25 +02:00
|
|
|
use Engelsystem\Models\Worklog;
|
|
|
|
use Illuminate\Support\Collection;
|
2017-12-29 17:19:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all work log entries for a user.
|
2018-01-14 18:09:34 +01:00
|
|
|
*
|
2019-12-27 05:24:32 +01:00
|
|
|
* @param int $userId
|
|
|
|
* @param Carbon|null $sinceTime
|
2020-09-12 19:45:25 +02:00
|
|
|
*
|
|
|
|
* @return Worklog[]|Collection
|
2017-12-29 17:19:27 +01:00
|
|
|
*/
|
2019-12-27 05:24:32 +01:00
|
|
|
function UserWorkLogsForUser($userId, Carbon $sinceTime = null)
|
2017-12-29 18:57:11 +01:00
|
|
|
{
|
2020-09-12 19:45:25 +02:00
|
|
|
$worklogs = Worklog::whereUserId($userId);
|
|
|
|
if ($sinceTime) {
|
|
|
|
$worklogs = $worklogs->whereDate('worked_at', '>=', $sinceTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $worklogs->get();
|
2017-12-29 17:19:27 +01:00
|
|
|
}
|