mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 20:22:15 +01:00
Moved from Request get to input function
This commit is contained in:
committed by
Constantin Graf
parent
ec239f20f2
commit
54d8c8a894
@@ -55,6 +55,7 @@ abstract class ApiException extends Exception
|
|||||||
*/
|
*/
|
||||||
public function report(): bool
|
public function report(): bool
|
||||||
{
|
{
|
||||||
return true;
|
// TODO: temporary activated
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class TimeEntryController extends Controller
|
|||||||
public function index(Organization $organization, TimeEntryIndexRequest $request): JsonResource
|
public function index(Organization $organization, TimeEntryIndexRequest $request): JsonResource
|
||||||
{
|
{
|
||||||
/** @var Member|null $member */
|
/** @var Member|null $member */
|
||||||
$member = $request->has('member_id') ? Member::query()->findOrFail($request->get('member_id')) : null;
|
$member = $request->has('member_id') ? Member::query()->findOrFail($request->input('member_id')) : null;
|
||||||
if ($member !== null && $member->user_id === Auth::id()) {
|
if ($member !== null && $member->user_id === Auth::id()) {
|
||||||
$this->checkPermission($organization, 'time-entries:view:own');
|
$this->checkPermission($organization, 'time-entries:view:own');
|
||||||
} else {
|
} else {
|
||||||
@@ -73,7 +73,7 @@ class TimeEntryController extends Controller
|
|||||||
$filter->addClientIdsFilter($request->input('client_ids'));
|
$filter->addClientIdsFilter($request->input('client_ids'));
|
||||||
$filter->addBillableFilter($request->input('billable'));
|
$filter->addBillableFilter($request->input('billable'));
|
||||||
|
|
||||||
$limit = $request->has('limit') ? (int) $request->get('limit', 100) : 100;
|
$limit = $request->has('limit') ? (int) $request->input('limit', 100) : 100;
|
||||||
if ($limit > 1000) {
|
if ($limit > 1000) {
|
||||||
$limit = 1000;
|
$limit = 1000;
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ class TimeEntryController extends Controller
|
|||||||
public function aggregate(Organization $organization, TimeEntryAggregateRequest $request, TimeEntryAggregationService $aggregationService): array
|
public function aggregate(Organization $organization, TimeEntryAggregateRequest $request, TimeEntryAggregationService $aggregationService): array
|
||||||
{
|
{
|
||||||
/** @var Member|null $member */
|
/** @var Member|null $member */
|
||||||
$member = $request->has('member_id') ? Member::query()->findOrFail($request->get('member_id')) : null;
|
$member = $request->has('member_id') ? Member::query()->findOrFail($request->input('member_id')) : null;
|
||||||
if ($member !== null && $member->user_id === Auth::id()) {
|
if ($member !== null && $member->user_id === Auth::id()) {
|
||||||
$this->checkPermission($organization, 'time-entries:view:own');
|
$this->checkPermission($organization, 'time-entries:view:own');
|
||||||
} else {
|
} else {
|
||||||
@@ -204,24 +204,24 @@ class TimeEntryController extends Controller
|
|||||||
public function store(Organization $organization, TimeEntryStoreRequest $request): JsonResource
|
public function store(Organization $organization, TimeEntryStoreRequest $request): JsonResource
|
||||||
{
|
{
|
||||||
/** @var Member $member */
|
/** @var Member $member */
|
||||||
$member = Member::query()->findOrFail($request->get('member_id'));
|
$member = Member::query()->findOrFail($request->input('member_id'));
|
||||||
if ($member->user_id === Auth::id()) {
|
if ($member->user_id === Auth::id()) {
|
||||||
$this->checkPermission($organization, 'time-entries:create:own');
|
$this->checkPermission($organization, 'time-entries:create:own');
|
||||||
} else {
|
} else {
|
||||||
$this->checkPermission($organization, 'time-entries:create:all');
|
$this->checkPermission($organization, 'time-entries:create:all');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->get('end') === null && TimeEntry::query()->whereBelongsTo($member, 'member')->where('end', null)->exists()) {
|
if ($request->input('end') === null && TimeEntry::query()->whereBelongsTo($member, 'member')->where('end', null)->exists()) {
|
||||||
throw new TimeEntryStillRunningApiException();
|
throw new TimeEntryStillRunningApiException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$client = $request->get('project_id') !== null ? Project::findOrFail($request->get('project_id'))->client : null;
|
$client = $request->input('project_id') !== null ? Project::findOrFail($request->input('project_id'))->client : null;
|
||||||
|
|
||||||
$timeEntry = new TimeEntry();
|
$timeEntry = new TimeEntry();
|
||||||
$timeEntry->fill($request->validated());
|
$timeEntry->fill($request->validated());
|
||||||
$timeEntry->client()->associate($client);
|
$timeEntry->client()->associate($client);
|
||||||
$timeEntry->user_id = $member->user_id;
|
$timeEntry->user_id = $member->user_id;
|
||||||
$timeEntry->description = $request->get('description') ?? '';
|
$timeEntry->description = $request->input('description') ?? '';
|
||||||
$timeEntry->organization()->associate($organization);
|
$timeEntry->organization()->associate($organization);
|
||||||
$timeEntry->setComputedAttributeValue('billable_rate');
|
$timeEntry->setComputedAttributeValue('billable_rate');
|
||||||
$timeEntry->save();
|
$timeEntry->save();
|
||||||
@@ -239,24 +239,24 @@ class TimeEntryController extends Controller
|
|||||||
public function update(Organization $organization, TimeEntry $timeEntry, TimeEntryUpdateRequest $request): JsonResource
|
public function update(Organization $organization, TimeEntry $timeEntry, TimeEntryUpdateRequest $request): JsonResource
|
||||||
{
|
{
|
||||||
/** @var Member|null $member */
|
/** @var Member|null $member */
|
||||||
$member = $request->has('member_id') ? Member::query()->findOrFail($request->get('member_id')) : null;
|
$member = $request->has('member_id') ? Member::query()->findOrFail($request->input('member_id')) : null;
|
||||||
if ($timeEntry->member->user_id === Auth::id() && ($member === null || $member->user_id === Auth::id())) {
|
if ($timeEntry->member->user_id === Auth::id() && ($member === null || $member->user_id === Auth::id())) {
|
||||||
$this->checkPermission($organization, 'time-entries:update:own');
|
$this->checkPermission($organization, 'time-entries:update:own');
|
||||||
} else {
|
} else {
|
||||||
$this->checkPermission($organization, 'time-entries:update:all');
|
$this->checkPermission($organization, 'time-entries:update:all');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($timeEntry->end !== null && $request->has('end') && $request->get('end') === null) {
|
if ($timeEntry->end !== null && $request->has('end') && $request->input('end') === null) {
|
||||||
throw new TimeEntryCanNotBeRestartedApiException();
|
throw new TimeEntryCanNotBeRestartedApiException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->has('project_id')) {
|
if ($request->has('project_id')) {
|
||||||
$client = $request->get('project_id') !== null ? Project::findOrFail($request->get('project_id'))->client : null;
|
$client = $request->input('project_id') !== null ? Project::findOrFail($request->input('project_id'))->client : null;
|
||||||
$timeEntry->client()->associate($client);
|
$timeEntry->client()->associate($client);
|
||||||
}
|
}
|
||||||
|
|
||||||
$timeEntry->fill($request->validated());
|
$timeEntry->fill($request->validated());
|
||||||
$timeEntry->description = $request->get('description', $timeEntry->description) ?? '';
|
$timeEntry->description = $request->input('description', $timeEntry->description) ?? '';
|
||||||
$timeEntry->save();
|
$timeEntry->save();
|
||||||
|
|
||||||
return new TimeEntryResource($timeEntry);
|
return new TimeEntryResource($timeEntry);
|
||||||
@@ -270,14 +270,14 @@ class TimeEntryController extends Controller
|
|||||||
$this->checkAnyPermission($organization, ['time-entries:update:all', 'time-entries:update:own']);
|
$this->checkAnyPermission($organization, ['time-entries:update:all', 'time-entries:update:own']);
|
||||||
$canAccessAll = $this->hasPermission($organization, 'time-entries:update:all');
|
$canAccessAll = $this->hasPermission($organization, 'time-entries:update:all');
|
||||||
|
|
||||||
$ids = $request->get('ids');
|
$ids = $request->input('ids');
|
||||||
|
|
||||||
$timeEntries = TimeEntry::query()
|
$timeEntries = TimeEntry::query()
|
||||||
->whereBelongsTo($organization, 'organization')
|
->whereBelongsTo($organization, 'organization')
|
||||||
->whereIn('id', $ids)
|
->whereIn('id', $ids)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$changes = $request->get('changes');
|
$changes = $request->input('changes');
|
||||||
|
|
||||||
if (isset($changes['member_id']) && ! $canAccessAll && $this->member($organization)->getKey() !== $changes['member_id']) {
|
if (isset($changes['member_id']) && ! $canAccessAll && $this->member($organization)->getKey() !== $changes['member_id']) {
|
||||||
throw new AuthorizationException();
|
throw new AuthorizationException();
|
||||||
|
|||||||
@@ -143,26 +143,26 @@ class TimeEntryAggregateRequest extends FormRequest
|
|||||||
|
|
||||||
public function getGroup(): ?TimeEntryAggregationType
|
public function getGroup(): ?TimeEntryAggregationType
|
||||||
{
|
{
|
||||||
return $this->get('group') !== null ? TimeEntryAggregationType::from($this->get('group')) : null;
|
return $this->input('group') !== null ? TimeEntryAggregationType::from($this->input('group')) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubGroup(): ?TimeEntryAggregationType
|
public function getSubGroup(): ?TimeEntryAggregationType
|
||||||
{
|
{
|
||||||
return $this->get('sub_group') !== null ? TimeEntryAggregationType::from($this->get('sub_group')) : null;
|
return $this->input('sub_group') !== null ? TimeEntryAggregationType::from($this->input('sub_group')) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFillGapsInTimeGroups(): bool
|
public function getFillGapsInTimeGroups(): bool
|
||||||
{
|
{
|
||||||
return $this->has('fill_gaps_in_time_groups') && $this->get('fill_gaps_in_time_groups') === 'true';
|
return $this->has('fill_gaps_in_time_groups') && $this->input('fill_gaps_in_time_groups') === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStart(): ?Carbon
|
public function getStart(): ?Carbon
|
||||||
{
|
{
|
||||||
return $this->get('start') !== null ? Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $this->get('start'), 'UTC') : null;
|
return $this->input('start') !== null ? Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $this->input('start'), 'UTC') : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEnd(): ?Carbon
|
public function getEnd(): ?Carbon
|
||||||
{
|
{
|
||||||
return $this->get('end') !== null ? Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $this->get('end'), 'UTC') : null;
|
return $this->input('end') !== null ? Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $this->input('end'), 'UTC') : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user