mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-09 16:52:17 +01:00
Add roles for project members; Restrict access to sensitive project values
This commit is contained in:
@@ -4,9 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\V1\ProjectMember;
|
||||
|
||||
use App\Enums\ProjectMemberRole;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* @property Organization $organization Organization from model binding
|
||||
@@ -16,7 +18,7 @@ class ProjectMemberUpdateRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<string|ValidationRule>>
|
||||
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -26,6 +28,10 @@ class ProjectMemberUpdateRequest extends FormRequest
|
||||
'integer',
|
||||
'min:0',
|
||||
],
|
||||
'role' => [
|
||||
'string',
|
||||
Rule::enum(ProjectMemberRole::class),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -33,6 +39,11 @@ class ProjectMemberUpdateRequest extends FormRequest
|
||||
{
|
||||
$input = $this->input('billable_rate');
|
||||
|
||||
return $input !== null && $input !== 0 ? (int) $this->input('billable_rate') : null;
|
||||
return $input !== null && ((int) $input) !== 0 ? (int) $this->validated('billable_rate') : null;
|
||||
}
|
||||
|
||||
public function getRole(): ?ProjectMemberRole
|
||||
{
|
||||
return $this->has('role') ? ProjectMemberRole::from($this->validated('role')) : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user