mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-10 09:12:15 +01:00
Added endpoint to update multiple time entries at once
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use App\Service\PermissionStore;
|
||||
@@ -28,6 +29,21 @@ class Controller extends \App\Http\Controllers\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string> $permissions
|
||||
*
|
||||
* @throws AuthorizationException
|
||||
*/
|
||||
protected function checkAnyPermission(Organization $organization, array $permissions): void
|
||||
{
|
||||
foreach ($permissions as $permission) {
|
||||
if ($this->permissionStore->has($organization, $permission)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
protected function hasPermission(Organization $organization, string $permission): bool
|
||||
{
|
||||
return $this->permissionStore->has($organization, $permission);
|
||||
@@ -47,4 +63,19 @@ class Controller extends \App\Http\Controllers\Controller
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws AuthorizationException
|
||||
*/
|
||||
protected function member(Organization $organization): Member
|
||||
{
|
||||
$user = $this->user();
|
||||
$member = Member::query()->whereBelongsTo($organization, 'organization')->whereBelongsTo($user, 'user')->first();
|
||||
if ($member === null) {
|
||||
Log::error('This function should only be called in authenticated context after checking the user is a member of the organization');
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
return $member;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user