mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 16:22:16 +01:00
Compare commits
2 Commits
feature/fi
...
feature/ch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9070f6cd7e | ||
|
|
919399e828 |
24
.github/workflows/build-private.yml
vendored
24
.github/workflows/build-private.yml
vendored
@@ -10,8 +10,6 @@ on:
|
|||||||
- '.github/workflows/build-private.yml'
|
- '.github/workflows/build-private.yml'
|
||||||
- 'docker/prod/**'
|
- 'docker/prod/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
name: Build - Private
|
name: Build - Private
|
||||||
jobs:
|
jobs:
|
||||||
@@ -19,7 +17,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Check out code"
|
- name: "Check out code"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -110,24 +107,6 @@ jobs:
|
|||||||
- name: "Install npm dependencies in services extension"
|
- name: "Install npm dependencies in services extension"
|
||||||
run: cd extensions/Services && npm ci
|
run: cd extensions/Services && npm ci
|
||||||
|
|
||||||
- name: "Checkout invoicing extension"
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: solidtime-io/extension-invoicing
|
|
||||||
path: extensions/Invoicing
|
|
||||||
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_INVOICING_EXTENSION }}
|
|
||||||
|
|
||||||
- name: "Install composer dependencies in invoicing extension"
|
|
||||||
uses: php-actions/composer@v6
|
|
||||||
with:
|
|
||||||
working_dir: "extensions/Invoicing"
|
|
||||||
command: install
|
|
||||||
only_args: --no-dev --no-ansi --no-interaction --prefer-dist --ignore-platform-reqs --classmap-authoritative
|
|
||||||
php_version: 8.3
|
|
||||||
|
|
||||||
- name: "Install npm dependencies in invoicing extension"
|
|
||||||
run: cd extensions/Invoicing && npm ci
|
|
||||||
|
|
||||||
- name: "Setup PHP with PECL extension"
|
- name: "Setup PHP with PECL extension"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
@@ -148,9 +127,6 @@ jobs:
|
|||||||
- name: "Activate services extension"
|
- name: "Activate services extension"
|
||||||
run: php artisan module:enable Services
|
run: php artisan module:enable Services
|
||||||
|
|
||||||
- name: "Activate invoicing extension"
|
|
||||||
run: php artisan module:enable Invoicing
|
|
||||||
|
|
||||||
- name: "Install npm dependencies"
|
- name: "Install npm dependencies"
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
|
|||||||
16
.github/workflows/build-public.yml
vendored
16
.github/workflows/build-public.yml
vendored
@@ -11,12 +11,6 @@ on:
|
|||||||
- 'docker/prod/**'
|
- 'docker/prod/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
contents: read
|
|
||||||
attestations: write
|
|
||||||
id-token: write
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOCKERHUB_REPO: solidtime/solidtime
|
DOCKERHUB_REPO: solidtime/solidtime
|
||||||
GHCR_REPO: ghcr.io/solidtime-io/solidtime
|
GHCR_REPO: ghcr.io/solidtime-io/solidtime
|
||||||
@@ -32,6 +26,11 @@ jobs:
|
|||||||
- runs-on: "ubuntu-24.04"
|
- runs-on: "ubuntu-24.04"
|
||||||
platform: "linux/amd64"
|
platform: "linux/amd64"
|
||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -164,6 +163,11 @@ jobs:
|
|||||||
|
|
||||||
merge:
|
merge:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
|
|||||||
3
.github/workflows/generate-api-docs.yml
vendored
3
.github/workflows/generate-api-docs.yml
vendored
@@ -3,9 +3,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
api_docs:
|
api_docs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/npm-build.yml
vendored
2
.github/workflows/npm-build.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: NPM Build
|
name: NPM Build
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
2
.github/workflows/npm-lint.yml
vendored
2
.github/workflows/npm-lint.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: NPM Lint
|
name: NPM Lint
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
2
.github/workflows/npm-publish-api.yml
vendored
2
.github/workflows/npm-publish-api.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: Publish API package to NPM
|
name: Publish API package to NPM
|
||||||
on:
|
on:
|
||||||
workflow_dispatch
|
workflow_dispatch
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/npm-publish-ui.yml
vendored
2
.github/workflows/npm-publish-ui.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: Publish UI package to NPM
|
name: Publish UI package to NPM
|
||||||
on:
|
on:
|
||||||
workflow_dispatch
|
workflow_dispatch
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
3
.github/workflows/npm-typecheck.yml
vendored
3
.github/workflows/npm-typecheck.yml
vendored
@@ -1,8 +1,7 @@
|
|||||||
name: NPM Typecheck
|
name: NPM Typecheck
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/phpstan.yml
vendored
2
.github/workflows/phpstan.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: Static code analysis (PHPStan)
|
name: Static code analysis (PHPStan)
|
||||||
on: push
|
on: push
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
phpstan:
|
phpstan:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
9
.github/workflows/phpunit.yml
vendored
9
.github/workflows/phpunit.yml
vendored
@@ -1,18 +1,13 @@
|
|||||||
name: PHPUnit Tests
|
name: PHPUnit Tests
|
||||||
on: push
|
on: push
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
phpunit:
|
phpunit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
postgres_version: [ 15, 16, 17 ]
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
pgsql_test:
|
pgsql_test:
|
||||||
image: postgres:${{ matrix.postgres_version }}
|
image: postgres:15
|
||||||
env:
|
env:
|
||||||
PGPASSWORD: 'root'
|
PGPASSWORD: 'root'
|
||||||
POSTGRES_DB: 'laravel'
|
POSTGRES_DB: 'laravel'
|
||||||
@@ -68,7 +63,7 @@ jobs:
|
|||||||
run: php artisan test --stop-on-failure --coverage-text --coverage-clover=coverage.xml
|
run: php artisan test --stop-on-failure --coverage-text --coverage-clover=coverage.xml
|
||||||
|
|
||||||
- name: "Upload coverage reports to Codecov"
|
- name: "Upload coverage reports to Codecov"
|
||||||
uses: codecov/codecov-action@v5.4.3
|
uses: codecov/codecov-action@v5.4.0
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
slug: solidtime-io/solidtime
|
slug: solidtime-io/solidtime
|
||||||
|
|||||||
2
.github/workflows/pint.yml
vendored
2
.github/workflows/pint.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: PHP Linting
|
name: PHP Linting
|
||||||
on: push
|
on: push
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
pint:
|
pint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/playwright.yml
vendored
2
.github/workflows/playwright.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: Playwright Tests
|
name: Playwright Tests
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
/**
|
/**
|
||||||
* Create a newly registered user.
|
* Create a newly registered user.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $input
|
* @param array<string, string> $input
|
||||||
*
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
@@ -76,11 +76,6 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
$ipLookupResponse = app(IpLookupServiceContract::class)->lookup(request()->ip());
|
$ipLookupResponse = app(IpLookupServiceContract::class)->lookup(request()->ip());
|
||||||
|
|
||||||
$startOfWeek = Weekday::Monday;
|
$startOfWeek = Weekday::Monday;
|
||||||
$numberFormat = null;
|
|
||||||
$currencyFormat = null;
|
|
||||||
$dateFormat = null;
|
|
||||||
$intervalFormat = null;
|
|
||||||
$timeFormat = null;
|
|
||||||
$currency = null;
|
$currency = null;
|
||||||
if ($ipLookupResponse !== null) {
|
if ($ipLookupResponse !== null) {
|
||||||
$startOfWeek = $ipLookupResponse->startOfWeek ?? Weekday::Monday;
|
$startOfWeek = $ipLookupResponse->startOfWeek ?? Weekday::Monday;
|
||||||
@@ -90,7 +85,7 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
$currency = $ipLookupResponse->currency;
|
$currency = $ipLookupResponse->currency;
|
||||||
}
|
}
|
||||||
$user = null;
|
$user = null;
|
||||||
DB::transaction(function () use (&$user, $input, $timezone, $startOfWeek, $currency, $numberFormat, $currencyFormat, $dateFormat, $intervalFormat, $timeFormat): void {
|
DB::transaction(function () use (&$user, $input, $timezone, $startOfWeek, $currency): void {
|
||||||
$userService = app(UserService::class);
|
$userService = app(UserService::class);
|
||||||
$user = $userService->createUser(
|
$user = $userService->createUser(
|
||||||
$input['name'],
|
$input['name'],
|
||||||
@@ -98,12 +93,7 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
$input['password'],
|
$input['password'],
|
||||||
$timezone ?? 'UTC',
|
$timezone ?? 'UTC',
|
||||||
$startOfWeek,
|
$startOfWeek,
|
||||||
$currency,
|
$currency ?? 'EUR',
|
||||||
$numberFormat,
|
|
||||||
$currencyFormat,
|
|
||||||
$dateFormat,
|
|
||||||
$intervalFormat,
|
|
||||||
$timeFormat
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Actions\Fortify;
|
|||||||
|
|
||||||
use App\Enums\Weekday;
|
use App\Enums\Weekday;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
@@ -58,7 +59,8 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
|||||||
$user->updateProfilePhoto($input['photo']);
|
$user->updateProfilePhoto($input['photo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input['email'] !== $user->email) {
|
if ($input['email'] !== $user->email &&
|
||||||
|
$user instanceof MustVerifyEmail) {
|
||||||
$user->forceFill([
|
$user->forceFill([
|
||||||
'name' => $input['name'],
|
'name' => $input['name'],
|
||||||
'email' => $input['email'],
|
'email' => $input['email'],
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class AddOrganizationMember implements AddsTeamMembers
|
|||||||
*/
|
*/
|
||||||
protected function rules(): array
|
protected function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return array_filter([
|
||||||
'email' => [
|
'email' => [
|
||||||
'required',
|
'required',
|
||||||
'email',
|
'email',
|
||||||
@@ -75,7 +75,7 @@ class AddOrganizationMember implements AddsTeamMembers
|
|||||||
Role::Employee->value,
|
Role::Employee->value,
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
];
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Actions\Jetstream;
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Enums\Role;
|
||||||
use App\Events\AfterCreateOrganization;
|
use App\Events\AfterCreateOrganization;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Service\IpLookup\IpLookupServiceContract;
|
|
||||||
use App\Service\OrganizationService;
|
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
@@ -34,18 +33,16 @@ class CreateOrganization implements CreatesTeams
|
|||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
])->validateWithBag('createTeam');
|
])->validateWithBag('createTeam');
|
||||||
|
|
||||||
$ipLookupResponse = app(IpLookupServiceContract::class)->lookup(request()->ip());
|
$organization = new Organization;
|
||||||
|
$organization->name = $input['name'];
|
||||||
|
$organization->personal_team = false;
|
||||||
|
$organization->owner()->associate($user);
|
||||||
|
$organization->save();
|
||||||
|
|
||||||
$currency = null;
|
$organization->users()->attach(
|
||||||
if ($ipLookupResponse !== null) {
|
$user, [
|
||||||
$currency = $ipLookupResponse->currency;
|
'role' => Role::Owner->value,
|
||||||
}
|
]
|
||||||
|
|
||||||
$organization = app(OrganizationService::class)->createOrganization(
|
|
||||||
$input['name'],
|
|
||||||
$user,
|
|
||||||
false,
|
|
||||||
$currency
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$user->switchTeam($organization);
|
$user->switchTeam($organization);
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ class UserCreateCommand extends Command
|
|||||||
$password,
|
$password,
|
||||||
'UTC',
|
'UTC',
|
||||||
Weekday::Monday,
|
Weekday::Monday,
|
||||||
null,
|
'EUR',
|
||||||
verifyEmail: $verifyEmail
|
$verifyEmail
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
/** @var Organization|null $organization */
|
/** @var Organization|null $organization */
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Console\Commands\Auth;
|
|
||||||
|
|
||||||
use App\Mail\AuthApiTokenExpirationReminderMail;
|
|
||||||
use App\Mail\AuthApiTokenExpiredMail;
|
|
||||||
use App\Models\Passport\Token;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
|
|
||||||
class AuthSendReminderForExpiringApiTokensCommand extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'auth:send-mails-expiring-api-tokens '.
|
|
||||||
' { --dry-run : Do not actually send emails or save anything to the database, just output what would happen }';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Sends emails about expiring API tokens, one week before and when they expired.';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*/
|
|
||||||
public function handle(): int
|
|
||||||
{
|
|
||||||
$dryRun = (bool) $this->option('dry-run');
|
|
||||||
if ($dryRun) {
|
|
||||||
$this->comment('Running in dry-run mode. No emails will be sent and nothing will be saved to the database.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->comment('Sending reminder emails about expiring API tokens...');
|
|
||||||
$sentMails = 0;
|
|
||||||
Token::query()
|
|
||||||
->where('expires_at', '<=', Carbon::now()->addDays(7))
|
|
||||||
->whereNull('reminder_sent_at')
|
|
||||||
->with([
|
|
||||||
'client',
|
|
||||||
'user',
|
|
||||||
])
|
|
||||||
->whereHas('user', function (Builder $query): void {
|
|
||||||
/** @var Builder<User> $query */
|
|
||||||
$query->where('is_placeholder', '=', false);
|
|
||||||
})
|
|
||||||
->isApiToken(true)
|
|
||||||
->orderBy('created_at', 'asc')
|
|
||||||
->chunk(500, function (Collection $tokens) use ($dryRun, &$sentMails): void {
|
|
||||||
/** @var Collection<int, Token> $tokens */
|
|
||||||
foreach ($tokens as $token) {
|
|
||||||
$user = $token->user;
|
|
||||||
$this->info('Start sending email to user "'.$user->email.'" ('.$user->getKey().') reminding about API token '.$token->getKey());
|
|
||||||
$sentMails++;
|
|
||||||
if (! $dryRun) {
|
|
||||||
Mail::to($user->email)
|
|
||||||
->queue(new AuthApiTokenExpirationReminderMail($token, $user));
|
|
||||||
$token->reminder_sent_at = Carbon::now();
|
|
||||||
$token->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$this->comment('Finished sending '.$sentMails.' expiring API token emails...');
|
|
||||||
|
|
||||||
$this->comment('Sent emails about expired API tokens');
|
|
||||||
$sentMails = 0;
|
|
||||||
Token::query()
|
|
||||||
->where('expires_at', '<=', Carbon::now())
|
|
||||||
->whereNull('expired_info_sent_at')
|
|
||||||
->with([
|
|
||||||
'client',
|
|
||||||
'user',
|
|
||||||
])
|
|
||||||
->whereHas('user', function (Builder $query): void {
|
|
||||||
/** @var Builder<User> $query */
|
|
||||||
$query->where('is_placeholder', '=', false);
|
|
||||||
})
|
|
||||||
->isApiToken(true)
|
|
||||||
->orderBy('created_at', 'asc')
|
|
||||||
->chunk(500, function (Collection $tokens) use ($dryRun, &$sentMails): void {
|
|
||||||
/** @var Collection<int, Token> $tokens */
|
|
||||||
foreach ($tokens as $token) {
|
|
||||||
$user = $token->user;
|
|
||||||
$this->info('Start sending email to user "'.$user->email.'" ('.$user->getKey().') about expired API token '.$token->getKey());
|
|
||||||
$sentMails++;
|
|
||||||
if (! $dryRun) {
|
|
||||||
Mail::to($user->email)
|
|
||||||
->queue(new AuthApiTokenExpiredMail($token, $user));
|
|
||||||
$token->expired_info_sent_at = Carbon::now();
|
|
||||||
$token->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$this->comment('Finished sending '.$sentMails.' expired API token emails...');
|
|
||||||
|
|
||||||
return self::SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Console\Commands\SelfHost;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Database\Query\Builder;
|
|
||||||
use Illuminate\Database\Query\JoinClause;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class SelfHostDatabaseConsistency extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'self-host:database-consistency';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*/
|
|
||||||
public function handle(): int
|
|
||||||
{
|
|
||||||
$hadAProblem = false;
|
|
||||||
|
|
||||||
// Task need to be part of project in time entries
|
|
||||||
$problems = DB::table('time_entries')
|
|
||||||
->select(['time_entries.id as id'])
|
|
||||||
->join('tasks', 'time_entries.task_id', '=', 'tasks.id')
|
|
||||||
->where('tasks.project_id', '!=', DB::raw('time_entries.project_id'))
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Time entries have a task that does not belong to the project of the time entry', $hadAProblem);
|
|
||||||
|
|
||||||
// Client id is the client id of the project
|
|
||||||
$problems = DB::table('time_entries')
|
|
||||||
->select(['time_entries.id as id'])
|
|
||||||
->join('projects', 'time_entries.project_id', '=', 'projects.id')
|
|
||||||
->where(DB::raw('coalesce(projects.client_id::varchar, \'\')'), '!=', DB::raw('coalesce(time_entries.client_id::varchar, \'\')'))
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Time entries have a client that does not match the client of the project', $hadAProblem);
|
|
||||||
|
|
||||||
// Client id can only be not null if the project id is not null
|
|
||||||
$problems = DB::table('time_entries')
|
|
||||||
->select(['time_entries.id as id'])
|
|
||||||
->whereNotNull('client_id')
|
|
||||||
->whereNull('project_id')
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Time entries have a client but no project', $hadAProblem);
|
|
||||||
|
|
||||||
// Every user needs to be a member of at least one organization
|
|
||||||
$problems = DB::table('users')
|
|
||||||
->select(['users.id as id'])
|
|
||||||
->leftJoin('members', 'users.id', '=', 'members.user_id')
|
|
||||||
->whereNull('members.id')
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Users are not member of any organization', $hadAProblem);
|
|
||||||
|
|
||||||
// Every organization needs at least an owner
|
|
||||||
$problems = DB::table('organizations')
|
|
||||||
->select(['organizations.id as id'])
|
|
||||||
->leftJoin('members', function (JoinClause $join): void {
|
|
||||||
$join->on('organizations.id', '=', 'members.organization_id')
|
|
||||||
->where('members.role', '=', 'owner');
|
|
||||||
})
|
|
||||||
->whereNull('members.id')
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Organizations without an owner', $hadAProblem);
|
|
||||||
|
|
||||||
// Every member can only have one running time entry
|
|
||||||
$problems = DB::table('time_entries')
|
|
||||||
->select(['user_id as id'])
|
|
||||||
->whereNull('end')
|
|
||||||
->groupBy('user_id')
|
|
||||||
->havingRaw('count(*) > 1')
|
|
||||||
->get(['user_id', DB::raw('count(*) as count')]);
|
|
||||||
$this->logProblems($problems, 'Users with more than one running time entry', $hadAProblem);
|
|
||||||
|
|
||||||
// Users have a current organization that they are not a member of
|
|
||||||
$problems = DB::table('users')
|
|
||||||
->select(['users.id as id'])
|
|
||||||
->whereNotNull('current_team_id')
|
|
||||||
->whereNotIn('current_team_id', function (Builder $query): void {
|
|
||||||
$query->select('organization_id')
|
|
||||||
->from('members')
|
|
||||||
->whereColumn('members.user_id', 'users.id');
|
|
||||||
})->get();
|
|
||||||
$this->logProblems($problems, 'Users have a current organization that they are not a member of', $hadAProblem);
|
|
||||||
|
|
||||||
return $hadAProblem ? self::FAILURE : self::SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection<int, \stdClass> $problems
|
|
||||||
*/
|
|
||||||
private function logProblems(Collection $problems, string $message, bool &$hadAProblem): void
|
|
||||||
{
|
|
||||||
$message = 'Consistency problem: '.$message;
|
|
||||||
if ($problems->isNotEmpty()) {
|
|
||||||
$ids = $problems->pluck('id');
|
|
||||||
$hadAProblem = true;
|
|
||||||
Log::error($message, [
|
|
||||||
'ids' => $ids,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$error = $message;
|
|
||||||
foreach ($ids as $id) {
|
|
||||||
$error .= "\n - ".$id;
|
|
||||||
}
|
|
||||||
$this->error($error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,10 +18,6 @@ class Kernel extends ConsoleKernel
|
|||||||
->when(fn (): bool => config('scheduling.tasks.time_entry_send_still_running_mails'))
|
->when(fn (): bool => config('scheduling.tasks.time_entry_send_still_running_mails'))
|
||||||
->everyTenMinutes();
|
->everyTenMinutes();
|
||||||
|
|
||||||
$schedule->command('auth:send-mails-expiring-api-tokens')
|
|
||||||
->when(fn (): bool => config('scheduling.tasks.auth_send_mails_expiring_api_tokens'))
|
|
||||||
->everyTenMinutes();
|
|
||||||
|
|
||||||
$schedule->command('self-host:check-for-update')
|
$schedule->command('self-host:check-for-update')
|
||||||
->when(fn (): bool => config('scheduling.tasks.self_hosting_check_for_update'))
|
->when(fn (): bool => config('scheduling.tasks.self_hosting_check_for_update'))
|
||||||
->twiceDaily();
|
->twiceDaily();
|
||||||
@@ -29,10 +25,6 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->command('self-host:telemetry')
|
$schedule->command('self-host:telemetry')
|
||||||
->when(fn (): bool => config('scheduling.tasks.self_hosting_telemetry'))
|
->when(fn (): bool => config('scheduling.tasks.self_hosting_telemetry'))
|
||||||
->twiceDaily();
|
->twiceDaily();
|
||||||
|
|
||||||
$schedule->command('self-host:database-consistency')
|
|
||||||
->when(fn (): bool => config('scheduling.tasks.self_hosting_database_consistency'))
|
|
||||||
->everySixHours();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum CurrencyFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case ISOCodeBeforeWithSpace = 'iso-code-before-with-space';
|
|
||||||
case ISOCodeAfterWithSpace = 'iso-code-after-with-space';
|
|
||||||
|
|
||||||
case SymbolBefore = 'symbol-before';
|
|
||||||
|
|
||||||
case SymbolAfter = 'symbol-after';
|
|
||||||
|
|
||||||
case SymbolBeforeWithSpace = 'symbol-before-with-space';
|
|
||||||
|
|
||||||
case SymbolAfterWithSpace = 'symbol-after-with-space';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.currency_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum DateFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case PointSeparatedDMYYYY = 'point-separated-d-m-yyyy';
|
|
||||||
case SlashSeparatedMMDDYYYY = 'slash-separated-mm-dd-yyyy';
|
|
||||||
|
|
||||||
case SlashSeparatedDDMMYYYY = 'slash-separated-dd-mm-yyyy';
|
|
||||||
|
|
||||||
case HyphenSeparatedDDMMYYY = 'hyphen-separated-dd-mm-yyyy';
|
|
||||||
|
|
||||||
case HyphenSeparatedMMDDDYYYY = 'hyphen-separated-mm-dd-yyyy';
|
|
||||||
|
|
||||||
case HyphenSeparatedYYYYMMDD = 'hyphen-separated-yyyy-mm-dd';
|
|
||||||
|
|
||||||
public function toCarbonFormat(): string
|
|
||||||
{
|
|
||||||
return match ($this->value) {
|
|
||||||
self::PointSeparatedDMYYYY->value => 'j.n.Y',
|
|
||||||
self::SlashSeparatedMMDDYYYY->value => 'm/d/Y',
|
|
||||||
self::SlashSeparatedDDMMYYYY->value => 'd/m/Y',
|
|
||||||
self::HyphenSeparatedDDMMYYY->value => 'd-m-Y',
|
|
||||||
self::HyphenSeparatedMMDDDYYYY->value => 'm-d-Y',
|
|
||||||
self::HyphenSeparatedYYYYMMDD->value => 'Y-m-d',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.date_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum IntervalFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case Decimal = 'decimal';
|
|
||||||
case HoursMinutes = 'hours-minutes';
|
|
||||||
|
|
||||||
case HoursMinutesColonSeparated = 'hours-minutes-colon-separated';
|
|
||||||
|
|
||||||
case HoursMinutesSecondsColonSeparated = 'hours-minutes-seconds-colon-separated';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.interval_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @info https://en.wikipedia.org/wiki/Decimal_separator
|
|
||||||
*/
|
|
||||||
enum NumberFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case ThousandsPointDecimalComma = 'point-comma';
|
|
||||||
|
|
||||||
case ThousandsCommaDecimalPoint = 'comma-point';
|
|
||||||
case ThousandsSpaceDecimalComma = 'space-comma';
|
|
||||||
|
|
||||||
case ThousandsSpaceDecimalPoint = 'space-point';
|
|
||||||
|
|
||||||
case ThousandsApostropheDecimalPoint = 'apostrophe-point';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.number_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum TimeEntryRoundingType: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case Up = 'up';
|
|
||||||
case Down = 'down';
|
|
||||||
case Nearest = 'nearest';
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum TimeFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case TwelveHours = '12-hours';
|
|
||||||
case TwentyFourHours = '24-hours';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.time_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Events;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
|
||||||
|
|
||||||
class DatabaseSeederAfterSeed
|
|
||||||
{
|
|
||||||
use Dispatchable;
|
|
||||||
|
|
||||||
public function __construct() {}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Events;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
|
||||||
|
|
||||||
class DatabaseSeederBeforeDelete
|
|
||||||
{
|
|
||||||
use Dispatchable;
|
|
||||||
|
|
||||||
public function __construct() {}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Exceptions\Api;
|
|
||||||
|
|
||||||
class InvitationForTheEmailAlreadyExistsApiException extends ApiException
|
|
||||||
{
|
|
||||||
public const string KEY = 'invitation_for_the_email_already_exists';
|
|
||||||
}
|
|
||||||
@@ -41,7 +41,9 @@ class PaginatedResourceCollectionTypeToSchema extends TypeToSchemaExtension
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$collectingType = $this->openApiTransformer->transform($collectingClassType);
|
if (! ($collectingType = $this->openApiTransformer->transform($collectingClassType))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$newType = new OpenApiObjectType;
|
$newType = new OpenApiObjectType;
|
||||||
$newType->addProperty('data', (new ArrayType)->setItems($collectingType));
|
$newType->addProperty('data', (new ArrayType)->setItems($collectingType));
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use Filament\Tables;
|
|||||||
use Filament\Tables\Columns\IconColumn;
|
use Filament\Tables\Columns\IconColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Novadaemon\FilamentPrettyJson\Form\PrettyJsonField;
|
use Novadaemon\FilamentPrettyJson\PrettyJson;
|
||||||
|
|
||||||
class AuditResource extends Resource
|
class AuditResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -38,8 +38,8 @@ class AuditResource extends Resource
|
|||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
Forms\Components\TextInput::make('auditable_id')
|
Forms\Components\TextInput::make('auditable_id')
|
||||||
->required(),
|
->required(),
|
||||||
PrettyJsonField::make('old_values'),
|
PrettyJson::make('old_values'),
|
||||||
PrettyJsonField::make('new_values'),
|
PrettyJson::make('new_values'),
|
||||||
Forms\Components\Textarea::make('url'),
|
Forms\Components\Textarea::make('url'),
|
||||||
Forms\Components\TextInput::make('ip_address'),
|
Forms\Components\TextInput::make('ip_address'),
|
||||||
Forms\Components\TextInput::make('user_agent')
|
Forms\Components\TextInput::make('user_agent')
|
||||||
|
|||||||
@@ -15,13 +15,12 @@ use Filament\Resources\Resource;
|
|||||||
use Filament\Tables\Actions\Action;
|
use Filament\Tables\Actions\Action;
|
||||||
use Filament\Tables\Actions\BulkAction;
|
use Filament\Tables\Actions\BulkAction;
|
||||||
use Filament\Tables\Actions\DeleteAction;
|
use Filament\Tables\Actions\DeleteAction;
|
||||||
use Filament\Tables\Actions\DeleteBulkAction;
|
|
||||||
use Filament\Tables\Actions\ViewAction;
|
use Filament\Tables\Actions\ViewAction;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Novadaemon\FilamentPrettyJson\Form\PrettyJsonField;
|
use Novadaemon\FilamentPrettyJson\PrettyJson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @source https://gitlab.com/amvisor/filament-failed-jobs
|
* @source https://gitlab.com/amvisor/filament-failed-jobs
|
||||||
@@ -51,7 +50,7 @@ class FailedJobResource extends Resource
|
|||||||
|
|
||||||
// make text a little bit smaller because often a complete Stack Trace is shown:
|
// make text a little bit smaller because often a complete Stack Trace is shown:
|
||||||
TextArea::make('exception')->disabled()->columnSpan(4)->extraInputAttributes(['style' => 'font-size: 80%;']),
|
TextArea::make('exception')->disabled()->columnSpan(4)->extraInputAttributes(['style' => 'font-size: 80%;']),
|
||||||
PrettyJsonField::make('payload')->disabled()->columnSpan(4),
|
PrettyJson::make('payload')->disabled()->columnSpan(4),
|
||||||
])->columns(4);
|
])->columns(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +75,7 @@ class FailedJobResource extends Resource
|
|||||||
->filters([])
|
->filters([])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
BulkAction::make('retry')
|
BulkAction::make('retry')
|
||||||
->icon('heroicon-o-arrow-path')
|
->label('Retry')
|
||||||
->label('Retry selected')
|
|
||||||
->requiresConfirmation()
|
->requiresConfirmation()
|
||||||
->action(function (Collection $records): void {
|
->action(function (Collection $records): void {
|
||||||
/** @var FailedJob $record */
|
/** @var FailedJob $record */
|
||||||
@@ -89,13 +87,11 @@ class FailedJobResource extends Resource
|
|||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
}),
|
}),
|
||||||
DeleteBulkAction::make(),
|
|
||||||
])
|
])
|
||||||
->actions([
|
->actions([
|
||||||
DeleteAction::make(),
|
DeleteAction::make('Delete'),
|
||||||
ViewAction::make(),
|
ViewAction::make('View'),
|
||||||
Action::make('retry')
|
Action::make('retry')
|
||||||
->icon('heroicon-o-arrow-path')
|
|
||||||
->label('Retry')
|
->label('Retry')
|
||||||
->requiresConfirmation()
|
->requiresConfirmation()
|
||||||
->action(function (FailedJob $record): void {
|
->action(function (FailedJob $record): void {
|
||||||
@@ -113,6 +109,7 @@ class FailedJobResource extends Resource
|
|||||||
return [
|
return [
|
||||||
'index' => ListFailedJobs::route('/'),
|
'index' => ListFailedJobs::route('/'),
|
||||||
'view' => ViewFailedJobs::route('/{record}'),
|
'view' => ViewFailedJobs::route('/{record}'),
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ namespace App\Filament\Resources\FailedJobResource\Pages;
|
|||||||
|
|
||||||
use App\Filament\Resources\FailedJobResource;
|
use App\Filament\Resources\FailedJobResource;
|
||||||
use App\Models\FailedJob;
|
use App\Models\FailedJob;
|
||||||
use Filament\Actions\Action;
|
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Pages\Actions\Action;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
||||||
@@ -19,8 +19,7 @@ class ListFailedJobs extends ListRecords
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Action::make('retry_all')
|
Action::make('retry_all')
|
||||||
->icon('heroicon-o-arrow-path')
|
->label('Retry all failed Jobs')
|
||||||
->label('Retry all')
|
|
||||||
->requiresConfirmation()
|
->requiresConfirmation()
|
||||||
->action(function (): void {
|
->action(function (): void {
|
||||||
Artisan::call('queue:retry all');
|
Artisan::call('queue:retry all');
|
||||||
@@ -31,8 +30,7 @@ class ListFailedJobs extends ListRecords
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
Action::make('delete_all')
|
Action::make('delete_all')
|
||||||
->icon('heroicon-o-trash')
|
->label('Delete all failed Jobs')
|
||||||
->label('Delete all')
|
|
||||||
->requiresConfirmation()
|
->requiresConfirmation()
|
||||||
->color('danger')
|
->color('danger')
|
||||||
->action(function (): void {
|
->action(function (): void {
|
||||||
|
|||||||
@@ -4,11 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Filament\Resources\OrganizationResource\Pages;
|
use App\Filament\Resources\OrganizationResource\Pages;
|
||||||
use App\Filament\Resources\OrganizationResource\RelationManagers\InvitationsRelationManager;
|
use App\Filament\Resources\OrganizationResource\RelationManagers\InvitationsRelationManager;
|
||||||
use App\Filament\Resources\OrganizationResource\RelationManagers\UsersRelationManager;
|
use App\Filament\Resources\OrganizationResource\RelationManagers\UsersRelationManager;
|
||||||
@@ -61,21 +56,6 @@ class OrganizationResource extends Resource
|
|||||||
->searchable(['name', 'email'])
|
->searchable(['name', 'email'])
|
||||||
->disabledOn(['edit'])
|
->disabledOn(['edit'])
|
||||||
->required(),
|
->required(),
|
||||||
Select::make('date_format')
|
|
||||||
->options(DateFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Select::make('currency_format')
|
|
||||||
->options(CurrencyFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Select::make('interval_format')
|
|
||||||
->options(IntervalFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Select::make('number_format')
|
|
||||||
->options(NumberFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Select::make('time_format')
|
|
||||||
->options(TimeFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('currency')
|
Forms\Components\Select::make('currency')
|
||||||
->label('Currency')
|
->label('Currency')
|
||||||
->options(function (): array {
|
->options(function (): array {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use Filament\Tables\Columns\TextColumn;
|
|||||||
use Filament\Tables\Columns\ToggleColumn;
|
use Filament\Tables\Columns\ToggleColumn;
|
||||||
use Filament\Tables\Filters\SelectFilter;
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Novadaemon\FilamentPrettyJson\Form\PrettyJsonField;
|
use Novadaemon\FilamentPrettyJson\PrettyJson;
|
||||||
|
|
||||||
class ReportResource extends Resource
|
class ReportResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -58,7 +58,7 @@ class ReportResource extends Resource
|
|||||||
Forms\Components\TextInput::make('share_secret')
|
Forms\Components\TextInput::make('share_secret')
|
||||||
->label('Share Secret')
|
->label('Share Secret')
|
||||||
->nullable(),
|
->nullable(),
|
||||||
PrettyJsonField::make('properties')
|
PrettyJson::make('properties')
|
||||||
->formatStateUsing(function (ReportPropertiesDto $state, Report $record): string {
|
->formatStateUsing(function (ReportPropertiesDto $state, Report $record): string {
|
||||||
return $record->getRawOriginal('properties');
|
return $record->getRawOriginal('properties');
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
use App\Filament\Resources\TokenResource\Pages;
|
use App\Filament\Resources\TokenResource\Pages;
|
||||||
|
use App\Models\Passport\Client;
|
||||||
use App\Models\Passport\Token;
|
use App\Models\Passport\Token;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -39,7 +40,7 @@ class TokenResource extends Resource
|
|||||||
->label('Name')
|
->label('Name')
|
||||||
->required()
|
->required()
|
||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
Forms\Components\Select::make('owner_id')
|
Forms\Components\Select::make('user_id')
|
||||||
->label('User')
|
->label('User')
|
||||||
->relationship(name: 'user', titleAttribute: 'name')
|
->relationship(name: 'user', titleAttribute: 'name')
|
||||||
->searchable(['name'])
|
->searchable(['name'])
|
||||||
@@ -78,12 +79,10 @@ class TokenResource extends Resource
|
|||||||
Tables\Columns\TextColumn::make('client.name')
|
Tables\Columns\TextColumn::make('client.name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\IconColumn::make('personal_access_client')
|
Tables\Columns\IconColumn::make('client.personal_access_client')
|
||||||
->state(function (Token $token): bool {
|
|
||||||
return in_array('personal_access', $token->client->grant_types ?? [], true);
|
|
||||||
})
|
|
||||||
->boolean()
|
->boolean()
|
||||||
->label('API token?'),
|
->label('API token?')
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\IconColumn::make('revoked')
|
Tables\Columns\IconColumn::make('revoked')
|
||||||
->boolean()
|
->boolean()
|
||||||
->label('Revoked?')
|
->label('Revoked?')
|
||||||
@@ -105,11 +104,17 @@ class TokenResource extends Resource
|
|||||||
->queries(
|
->queries(
|
||||||
true: function (Builder $query) {
|
true: function (Builder $query) {
|
||||||
/** @var Builder<Token> $query */
|
/** @var Builder<Token> $query */
|
||||||
return $query->isApiToken();
|
return $query->whereHas('client', function (Builder $query) {
|
||||||
|
/** @var Builder<Client> $query */
|
||||||
|
return $query->where('personal_access_client', true);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
false: function (Builder $query) {
|
false: function (Builder $query) {
|
||||||
/** @var Builder<Token> $query */
|
/** @var Builder<Token> $query */
|
||||||
return $query->isApiToken(false);
|
return $query->whereHas('client', function (Builder $query) {
|
||||||
|
/** @var Builder<Client> $query */
|
||||||
|
return $query->where('personal_access_client', false);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
blank: function (Builder $query) {
|
blank: function (Builder $query) {
|
||||||
/** @var Builder<Token> $query */
|
/** @var Builder<Token> $query */
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use Filament\Tables;
|
|||||||
use Filament\Tables\Filters\TernaryFilter;
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
@@ -208,14 +207,6 @@ class UserResource extends Resource
|
|||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
Tables\Actions\BulkAction::make('Resend verification email')
|
|
||||||
->icon('heroicon-o-paper-airplane')
|
|
||||||
->action(function (Collection $records): void {
|
|
||||||
foreach ($records as $user) {
|
|
||||||
/** @var User $user */
|
|
||||||
$user->sendEmailVerificationNotification();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CreateUser extends CreateRecord
|
|||||||
$data['timezone'],
|
$data['timezone'],
|
||||||
Weekday::from($data['week_start']),
|
Weekday::from($data['week_start']),
|
||||||
$data['currency'],
|
$data['currency'],
|
||||||
verifyEmail: (bool) $data['is_email_verified']
|
(bool) $data['is_email_verified']
|
||||||
);
|
);
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
|||||||
@@ -8,12 +8,9 @@ use App\Exceptions\Api\PersonalAccessClientIsNotConfiguredException;
|
|||||||
use App\Http\Requests\V1\ApiToken\ApiTokenStoreRequest;
|
use App\Http\Requests\V1\ApiToken\ApiTokenStoreRequest;
|
||||||
use App\Http\Resources\V1\ApiToken\ApiTokenCollection;
|
use App\Http\Resources\V1\ApiToken\ApiTokenCollection;
|
||||||
use App\Http\Resources\V1\ApiToken\ApiTokenWithAccessTokenResource;
|
use App\Http\Resources\V1\ApiToken\ApiTokenWithAccessTokenResource;
|
||||||
use App\Models\Passport\Client;
|
|
||||||
use App\Models\Passport\Token;
|
use App\Models\Passport\Token;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class ApiTokenController extends Controller
|
class ApiTokenController extends Controller
|
||||||
{
|
{
|
||||||
@@ -31,10 +28,7 @@ class ApiTokenController extends Controller
|
|||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
|
|
||||||
$tokens = $user->tokens()
|
$tokens = $user->tokens()
|
||||||
->whereHas('client', function (Builder $query): void {
|
->where('client_id', '=', config('passport.personal_access_client.id'))
|
||||||
/** @var Builder<Client> $query */
|
|
||||||
$query->whereJsonContains('grant_types', 'personal_access');
|
|
||||||
})
|
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return new ApiTokenCollection($tokens);
|
return new ApiTokenCollection($tokens);
|
||||||
@@ -54,21 +48,15 @@ class ApiTokenController extends Controller
|
|||||||
{
|
{
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
|
|
||||||
try {
|
if (config('passport.personal_access_client.id') === null || config('passport.personal_access_client.secret') === null) {
|
||||||
$token = $user->createToken($request->getName(), ['*']);
|
throw new PersonalAccessClientIsNotConfiguredException;
|
||||||
|
|
||||||
/** @var Token $tokenModel */
|
|
||||||
$tokenModel = $token->getToken();
|
|
||||||
|
|
||||||
return new ApiTokenWithAccessTokenResource($tokenModel, $token->accessToken);
|
|
||||||
} catch (\RuntimeException $exception) {
|
|
||||||
report($exception);
|
|
||||||
if (Str::contains($exception->getMessage(), ['Personal access client not found'])) {
|
|
||||||
throw new PersonalAccessClientIsNotConfiguredException;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw $exception;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$token = $user->createToken($request->getName(), ['*']);
|
||||||
|
/** @var Token $tokenModel */
|
||||||
|
$tokenModel = $token->token;
|
||||||
|
|
||||||
|
return new ApiTokenWithAccessTokenResource($tokenModel, $token->accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,10 +71,13 @@ class ApiTokenController extends Controller
|
|||||||
{
|
{
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
|
|
||||||
|
if (config('passport.personal_access_client.id') === null || config('passport.personal_access_client.secret') === null) {
|
||||||
|
throw new PersonalAccessClientIsNotConfiguredException;
|
||||||
|
}
|
||||||
if ($apiToken->user_id !== $user->getKey()) {
|
if ($apiToken->user_id !== $user->getKey()) {
|
||||||
throw new AuthorizationException('API token does not belong to user');
|
throw new AuthorizationException('API token does not belong to user');
|
||||||
}
|
}
|
||||||
if (! ($apiToken->client?->hasGrantType('personal_access') ?? false)) {
|
if ($apiToken->client_id !== config('passport.personal_access_client.id')) {
|
||||||
throw new AuthorizationException('API token is not a personal access token');
|
throw new AuthorizationException('API token is not a personal access token');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,10 +97,13 @@ class ApiTokenController extends Controller
|
|||||||
{
|
{
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
|
|
||||||
|
if (config('passport.personal_access_client.id') === null || config('passport.personal_access_client.secret') === null) {
|
||||||
|
throw new PersonalAccessClientIsNotConfiguredException;
|
||||||
|
}
|
||||||
if ($apiToken->user_id !== $user->getKey()) {
|
if ($apiToken->user_id !== $user->getKey()) {
|
||||||
throw new AuthorizationException('API token does not belong to user');
|
throw new AuthorizationException('API token does not belong to user');
|
||||||
}
|
}
|
||||||
if (! ($apiToken->client?->hasGrantType('personal_access') ?? false)) {
|
if ($apiToken->client_id !== config('passport.personal_access_client.id')) {
|
||||||
throw new AuthorizationException('API token is not a personal access token');
|
throw new AuthorizationException('API token is not a personal access token');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\V1;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Service\CurrencyService;
|
|
||||||
use Brick\Money\Currency;
|
|
||||||
use Brick\Money\ISOCurrencyProvider;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
|
|
||||||
class CurrencyController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get all currencies
|
|
||||||
*
|
|
||||||
* @response array{code: string, name: string, symbol: string}[]
|
|
||||||
*
|
|
||||||
* @operationId getCurrencies
|
|
||||||
*/
|
|
||||||
public function index(): JsonResponse
|
|
||||||
{
|
|
||||||
$currencyService = app(CurrencyService::class);
|
|
||||||
|
|
||||||
$currencies = array_values(array_map(
|
|
||||||
fn (Currency $currency): array => [
|
|
||||||
'code' => $currency->getCurrencyCode(),
|
|
||||||
'name' => $currency->getName(),
|
|
||||||
'symbol' => $currencyService->getCurrencySymbol($currency->getCurrencyCode()),
|
|
||||||
],
|
|
||||||
ISOCurrencyProvider::getInstance()->getAvailableCurrencies()
|
|
||||||
));
|
|
||||||
|
|
||||||
return response()->json($currencies);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Api\V1;
|
namespace App\Http\Controllers\Api\V1;
|
||||||
|
|
||||||
use App\Exceptions\Api\InvitationForTheEmailAlreadyExistsApiException;
|
|
||||||
use App\Exceptions\Api\UserIsAlreadyMemberOfOrganizationApiException;
|
use App\Exceptions\Api\UserIsAlreadyMemberOfOrganizationApiException;
|
||||||
use App\Http\Requests\V1\Invitation\InvitationIndexRequest;
|
use App\Http\Requests\V1\Invitation\InvitationIndexRequest;
|
||||||
use App\Http\Requests\V1\Invitation\InvitationStoreRequest;
|
use App\Http\Requests\V1\Invitation\InvitationStoreRequest;
|
||||||
@@ -51,7 +50,6 @@ class InvitationController extends Controller
|
|||||||
*
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
* @throws UserIsAlreadyMemberOfOrganizationApiException
|
* @throws UserIsAlreadyMemberOfOrganizationApiException
|
||||||
* @throws InvitationForTheEmailAlreadyExistsApiException
|
|
||||||
*
|
*
|
||||||
* @operationId invite
|
* @operationId invite
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,14 +10,12 @@ use App\Exceptions\Api\CanNotRemoveOwnerFromOrganization;
|
|||||||
use App\Exceptions\Api\ChangingRoleOfPlaceholderIsNotAllowed;
|
use App\Exceptions\Api\ChangingRoleOfPlaceholderIsNotAllowed;
|
||||||
use App\Exceptions\Api\ChangingRoleToPlaceholderIsNotAllowed;
|
use App\Exceptions\Api\ChangingRoleToPlaceholderIsNotAllowed;
|
||||||
use App\Exceptions\Api\EntityStillInUseApiException;
|
use App\Exceptions\Api\EntityStillInUseApiException;
|
||||||
use App\Exceptions\Api\InvitationForTheEmailAlreadyExistsApiException;
|
|
||||||
use App\Exceptions\Api\OnlyOwnerCanChangeOwnership;
|
use App\Exceptions\Api\OnlyOwnerCanChangeOwnership;
|
||||||
use App\Exceptions\Api\OnlyPlaceholdersCanBeMergedIntoAnotherMember;
|
use App\Exceptions\Api\OnlyPlaceholdersCanBeMergedIntoAnotherMember;
|
||||||
use App\Exceptions\Api\OrganizationNeedsAtLeastOneOwner;
|
use App\Exceptions\Api\OrganizationNeedsAtLeastOneOwner;
|
||||||
use App\Exceptions\Api\ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException;
|
use App\Exceptions\Api\ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException;
|
||||||
use App\Exceptions\Api\UserIsAlreadyMemberOfOrganizationApiException;
|
use App\Exceptions\Api\UserIsAlreadyMemberOfOrganizationApiException;
|
||||||
use App\Exceptions\Api\UserNotPlaceholderApiException;
|
use App\Exceptions\Api\UserNotPlaceholderApiException;
|
||||||
use App\Http\Requests\V1\Member\MemberDestroyRequest;
|
|
||||||
use App\Http\Requests\V1\Member\MemberIndexRequest;
|
use App\Http\Requests\V1\Member\MemberIndexRequest;
|
||||||
use App\Http\Requests\V1\Member\MemberMergeIntoRequest;
|
use App\Http\Requests\V1\Member\MemberMergeIntoRequest;
|
||||||
use App\Http\Requests\V1\Member\MemberUpdateRequest;
|
use App\Http\Requests\V1\Member\MemberUpdateRequest;
|
||||||
@@ -102,13 +100,11 @@ class MemberController extends Controller
|
|||||||
*
|
*
|
||||||
* @operationId removeMember
|
* @operationId removeMember
|
||||||
*/
|
*/
|
||||||
public function destroy(MemberDestroyRequest $request, Organization $organization, Member $member, MemberService $memberService): JsonResponse
|
public function destroy(Organization $organization, Member $member, MemberService $memberService): JsonResponse
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'members:delete', $member);
|
$this->checkPermission($organization, 'members:delete', $member);
|
||||||
|
|
||||||
$deleteRelated = $request->getDeleteRelated();
|
$memberService->removeMember($member, $organization);
|
||||||
|
|
||||||
$memberService->removeMember($member, $organization, $deleteRelated);
|
|
||||||
|
|
||||||
return response()
|
return response()
|
||||||
->json(null, 204);
|
->json(null, 204);
|
||||||
@@ -140,8 +136,6 @@ class MemberController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge one member into another
|
|
||||||
*
|
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
* @throws OnlyPlaceholdersCanBeMergedIntoAnotherMember
|
* @throws OnlyPlaceholdersCanBeMergedIntoAnotherMember
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
@@ -174,7 +168,6 @@ class MemberController extends Controller
|
|||||||
* @throws UserNotPlaceholderApiException
|
* @throws UserNotPlaceholderApiException
|
||||||
* @throws UserIsAlreadyMemberOfOrganizationApiException
|
* @throws UserIsAlreadyMemberOfOrganizationApiException
|
||||||
* @throws ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException
|
* @throws ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException
|
||||||
* @throws InvitationForTheEmailAlreadyExistsApiException
|
|
||||||
*
|
*
|
||||||
* @operationId invitePlaceholder
|
* @operationId invitePlaceholder
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,35 +40,15 @@ class OrganizationController extends Controller
|
|||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'organizations:update');
|
$this->checkPermission($organization, 'organizations:update');
|
||||||
|
|
||||||
if ($request->getName() !== null) {
|
$organization->name = $request->input('name');
|
||||||
$organization->name = $request->getName();
|
$oldBillableRate = $organization->billable_rate;
|
||||||
}
|
if ($request->has('employees_can_see_billable_rates')) {
|
||||||
if ($request->getEmployeesCanSeeBillableRates() !== null) {
|
$organization->employees_can_see_billable_rates = $request->validated('employees_can_see_billable_rates');
|
||||||
$organization->employees_can_see_billable_rates = $request->getEmployeesCanSeeBillableRates();
|
|
||||||
}
|
|
||||||
if ($request->getNumberFormat() !== null) {
|
|
||||||
$organization->number_format = $request->getNumberFormat();
|
|
||||||
}
|
|
||||||
if ($request->getCurrencyFormat() !== null) {
|
|
||||||
$organization->currency_format = $request->getCurrencyFormat();
|
|
||||||
}
|
|
||||||
if ($request->getDateFormat() !== null) {
|
|
||||||
$organization->date_format = $request->getDateFormat();
|
|
||||||
}
|
|
||||||
if ($request->getIntervalFormat() !== null) {
|
|
||||||
$organization->interval_format = $request->getIntervalFormat();
|
|
||||||
}
|
|
||||||
if ($request->getTimeFormat() !== null) {
|
|
||||||
$organization->time_format = $request->getTimeFormat();
|
|
||||||
}
|
|
||||||
$hasBillableRate = $request->has('billable_rate');
|
|
||||||
if ($hasBillableRate) {
|
|
||||||
$oldBillableRate = $organization->billable_rate;
|
|
||||||
$organization->billable_rate = $request->getBillableRate();
|
|
||||||
}
|
}
|
||||||
|
$organization->billable_rate = $request->getBillableRate();
|
||||||
$organization->save();
|
$organization->save();
|
||||||
|
|
||||||
if ($hasBillableRate && $oldBillableRate !== $request->getBillableRate()) {
|
if ($oldBillableRate !== $request->getBillableRate()) {
|
||||||
$billableRateService->updateTimeEntriesBillableRateForOrganization($organization);
|
$billableRateService->updateTimeEntriesBillableRateForOrganization($organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,9 +73,7 @@ class ReportController extends Controller
|
|||||||
false,
|
false,
|
||||||
$report->properties->start,
|
$report->properties->start,
|
||||||
$report->properties->end,
|
$report->properties->end,
|
||||||
true,
|
true
|
||||||
$report->properties->roundingType,
|
|
||||||
$report->properties->roundingMinutes,
|
|
||||||
);
|
);
|
||||||
$historyData = $timeEntryAggregationService->getAggregatedTimeEntriesWithDescriptions(
|
$historyData = $timeEntryAggregationService->getAggregatedTimeEntriesWithDescriptions(
|
||||||
$timeEntriesQuery->clone(),
|
$timeEntriesQuery->clone(),
|
||||||
@@ -86,9 +84,7 @@ class ReportController extends Controller
|
|||||||
true,
|
true,
|
||||||
$report->properties->start,
|
$report->properties->start,
|
||||||
$report->properties->end,
|
$report->properties->end,
|
||||||
true,
|
true
|
||||||
$report->properties->roundingType,
|
|
||||||
$report->properties->roundingMinutes,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return new DetailedWithDataReportResource($report, $data, $historyData);
|
return new DetailedWithDataReportResource($report, $data, $historyData);
|
||||||
|
|||||||
@@ -107,8 +107,6 @@ class ReportController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$properties->timezone = $timezone;
|
$properties->timezone = $timezone;
|
||||||
$properties->roundingType = $request->getPropertyRoundingType();
|
|
||||||
$properties->roundingMinutes = $request->getPropertyRoundingMinutes();
|
|
||||||
$report->properties = $properties;
|
$report->properties = $properties;
|
||||||
if ($isPublic) {
|
if ($isPublic) {
|
||||||
$report->share_secret = $reportService->generateSecret();
|
$report->share_secret = $reportService->generateSecret();
|
||||||
|
|||||||
@@ -27,13 +27,11 @@ use App\Models\Organization;
|
|||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
use App\Service\LocalizationService;
|
|
||||||
use App\Service\ReportExport\TimeEntriesDetailedCsvExport;
|
use App\Service\ReportExport\TimeEntriesDetailedCsvExport;
|
||||||
use App\Service\ReportExport\TimeEntriesDetailedExport;
|
use App\Service\ReportExport\TimeEntriesDetailedExport;
|
||||||
use App\Service\ReportExport\TimeEntriesReportExport;
|
use App\Service\ReportExport\TimeEntriesReportExport;
|
||||||
use App\Service\TimeEntryAggregationService;
|
use App\Service\TimeEntryAggregationService;
|
||||||
use App\Service\TimeEntryFilter;
|
use App\Service\TimeEntryFilter;
|
||||||
use App\Service\TimeEntryService;
|
|
||||||
use App\Service\TimezoneService;
|
use App\Service\TimezoneService;
|
||||||
use Gotenberg\Exceptions\GotenbergApiErrored;
|
use Gotenberg\Exceptions\GotenbergApiErrored;
|
||||||
use Gotenberg\Exceptions\NoOutputFileInResponse;
|
use Gotenberg\Exceptions\NoOutputFileInResponse;
|
||||||
@@ -48,7 +46,6 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Blade;
|
use Illuminate\Support\Facades\Blade;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
@@ -86,8 +83,7 @@ class TimeEntryController extends Controller
|
|||||||
$this->checkPermission($organization, 'time-entries:view:all');
|
$this->checkPermission($organization, 'time-entries:view:all');
|
||||||
}
|
}
|
||||||
|
|
||||||
$canAccessPremiumFeatures = $this->canAccessPremiumFeatures($organization);
|
$timeEntriesQuery = $this->getTimeEntriesQuery($organization, $request, $member);
|
||||||
$timeEntriesQuery = $this->getTimeEntriesQuery($organization, $request, $member, $canAccessPremiumFeatures);
|
|
||||||
|
|
||||||
$totalCount = $timeEntriesQuery->count();
|
$totalCount = $timeEntriesQuery->count();
|
||||||
|
|
||||||
@@ -141,19 +137,10 @@ class TimeEntryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @return Builder<TimeEntry>
|
* @return Builder<TimeEntry>
|
||||||
*/
|
*/
|
||||||
private function getTimeEntriesQuery(Organization $organization, TimeEntryIndexRequest|TimeEntryIndexExportRequest $request, ?Member $member, bool $canAccessPremiumFeatures): Builder
|
private function getTimeEntriesQuery(Organization $organization, TimeEntryIndexRequest|TimeEntryIndexExportRequest $request, ?Member $member): Builder
|
||||||
{
|
{
|
||||||
$select = TimeEntry::SELECT_COLUMNS;
|
|
||||||
$roundingType = $canAccessPremiumFeatures ? $request->getRoundingType() : null;
|
|
||||||
$roundingMinutes = $canAccessPremiumFeatures ? $request->getRoundingMinutes() : null;
|
|
||||||
if ($roundingType !== null && $roundingMinutes !== null) {
|
|
||||||
$select = array_diff($select, ['start', 'end']);
|
|
||||||
$select[] = DB::raw(app(TimeEntryService::class)->getStartSelectRawForRounding($roundingType, $roundingMinutes).' as start');
|
|
||||||
$select[] = DB::raw(app(TimeEntryService::class)->getEndSelectRawForRounding($roundingType, $roundingMinutes).' as end');
|
|
||||||
}
|
|
||||||
$timeEntriesQuery = TimeEntry::query()
|
$timeEntriesQuery = TimeEntry::query()
|
||||||
->whereBelongsTo($organization, 'organization')
|
->whereBelongsTo($organization, 'organization')
|
||||||
->select($select)
|
|
||||||
->orderBy('start', 'desc');
|
->orderBy('start', 'desc');
|
||||||
|
|
||||||
$filter = new TimeEntryFilter($timeEntriesQuery);
|
$filter = new TimeEntryFilter($timeEntriesQuery);
|
||||||
@@ -187,19 +174,16 @@ class TimeEntryController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
$this->checkPermission($organization, 'time-entries:view:all');
|
$this->checkPermission($organization, 'time-entries:view:all');
|
||||||
}
|
}
|
||||||
$canAccessPremiumFeatures = $this->canAccessPremiumFeatures($organization);
|
|
||||||
$debug = $request->getDebug();
|
$debug = $request->getDebug();
|
||||||
$format = $request->getFormatValue();
|
$format = $request->getFormatValue();
|
||||||
if ($format === ExportFormat::PDF && ! $canAccessPremiumFeatures) {
|
if ($format === ExportFormat::PDF && ! $this->canAccessPremiumFeatures($organization)) {
|
||||||
throw new FeatureIsNotAvailableInFreePlanApiException;
|
throw new FeatureIsNotAvailableInFreePlanApiException;
|
||||||
}
|
}
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$timezone = $user->timezone;
|
$timezone = $user->timezone;
|
||||||
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
||||||
$roundingType = $canAccessPremiumFeatures ? $request->getRoundingType() : null;
|
|
||||||
$roundingMinutes = $canAccessPremiumFeatures ? $request->getRoundingMinutes() : null;
|
|
||||||
|
|
||||||
$timeEntriesQuery = $this->getTimeEntriesQuery($organization, $request, $member, $canAccessPremiumFeatures);
|
$timeEntriesQuery = $this->getTimeEntriesQuery($organization, $request, $member);
|
||||||
$timeEntriesQuery->with([
|
$timeEntriesQuery->with([
|
||||||
'task',
|
'task',
|
||||||
'client',
|
'client',
|
||||||
@@ -210,7 +194,6 @@ class TimeEntryController extends Controller
|
|||||||
$filename = 'time-entries-export-'.now()->format('Y-m-d_H-i-s').'.'.$format->getFileExtension();
|
$filename = 'time-entries-export-'.now()->format('Y-m-d_H-i-s').'.'.$format->getFileExtension();
|
||||||
$folderPath = 'exports';
|
$folderPath = 'exports';
|
||||||
$path = $folderPath.'/'.$filename;
|
$path = $folderPath.'/'.$filename;
|
||||||
$localizationService = LocalizationService::forOrganization($organization);
|
|
||||||
if ($format === ExportFormat::CSV) {
|
if ($format === ExportFormat::CSV) {
|
||||||
$export = new TimeEntriesDetailedCsvExport(config('filesystems.private'), $folderPath, $filename, $timeEntriesQuery, 1000, $timezone);
|
$export = new TimeEntriesDetailedCsvExport(config('filesystems.private'), $folderPath, $filename, $timeEntriesQuery, 1000, $timezone);
|
||||||
$export->export();
|
$export->export();
|
||||||
@@ -222,9 +205,8 @@ class TimeEntryController extends Controller
|
|||||||
if ($viewFile === false) {
|
if ($viewFile === false) {
|
||||||
throw new \LogicException('View file not found');
|
throw new \LogicException('View file not found');
|
||||||
}
|
}
|
||||||
$timeEntriesAggregateQuery = $this->getTimeEntriesAggregateQuery($organization, $request, $member);
|
|
||||||
$aggregatedData = $timeEntryAggregationService->getAggregatedTimeEntries(
|
$aggregatedData = $timeEntryAggregationService->getAggregatedTimeEntries(
|
||||||
$timeEntriesAggregateQuery,
|
$timeEntriesQuery->clone()->reorder()->withOnly([]),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
$user->timezone,
|
$user->timezone,
|
||||||
@@ -232,9 +214,7 @@ class TimeEntryController extends Controller
|
|||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
$showBillableRate,
|
$showBillableRate
|
||||||
$roundingType,
|
|
||||||
$roundingMinutes,
|
|
||||||
);
|
);
|
||||||
$html = Blade::render($viewFile, [
|
$html = Blade::render($viewFile, [
|
||||||
'timeEntries' => $timeEntriesQuery->get(),
|
'timeEntries' => $timeEntriesQuery->get(),
|
||||||
@@ -243,8 +223,6 @@ class TimeEntryController extends Controller
|
|||||||
'currency' => $organization->currency,
|
'currency' => $organization->currency,
|
||||||
'start' => $request->getStart()->timezone($timezone),
|
'start' => $request->getStart()->timezone($timezone),
|
||||||
'end' => $request->getEnd()->timezone($timezone),
|
'end' => $request->getEnd()->timezone($timezone),
|
||||||
'localization' => $localizationService,
|
|
||||||
'showBillableRate' => $showBillableRate,
|
|
||||||
]);
|
]);
|
||||||
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-index/pdf-footer.blade.php'));
|
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-index/pdf-footer.blade.php'));
|
||||||
if ($footerViewFile === false) {
|
if ($footerViewFile === false) {
|
||||||
@@ -279,7 +257,7 @@ class TimeEntryController extends Controller
|
|||||||
->putFileAs($folderPath, new File($tempFolder->path($filenameTemp)), $filename);
|
->putFileAs($folderPath, new File($tempFolder->path($filenameTemp)), $filename);
|
||||||
} else {
|
} else {
|
||||||
Excel::store(
|
Excel::store(
|
||||||
new TimeEntriesDetailedExport($timeEntriesQuery, $format, $timezone, $localizationService),
|
new TimeEntriesDetailedExport($timeEntriesQuery, $format, $timezone),
|
||||||
$path,
|
$path,
|
||||||
config('filesystems.private'),
|
config('filesystems.private'),
|
||||||
$format->getExportPackageType(),
|
$format->getExportPackageType(),
|
||||||
@@ -336,15 +314,12 @@ class TimeEntryController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
$this->checkPermission($organization, 'time-entries:view:all');
|
$this->checkPermission($organization, 'time-entries:view:all');
|
||||||
}
|
}
|
||||||
$canAccessPremiumFeatures = $this->canAccessPremiumFeatures($organization);
|
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
||||||
|
|
||||||
$group1Type = $request->getGroup();
|
$group1Type = $request->getGroup();
|
||||||
$group2Type = $request->getSubGroup();
|
$group2Type = $request->getSubGroup();
|
||||||
$timeEntriesAggregateQuery = $this->getTimeEntriesAggregateQuery($organization, $request, $member);
|
$timeEntriesAggregateQuery = $this->getTimeEntriesAggregateQuery($organization, $request, $member);
|
||||||
$roundingType = $canAccessPremiumFeatures ? $request->getRoundingType() : null;
|
|
||||||
$roundingMinutes = $canAccessPremiumFeatures ? $request->getRoundingMinutes() : null;
|
|
||||||
|
|
||||||
$aggregatedData = $timeEntryAggregationService->getAggregatedTimeEntries(
|
$aggregatedData = $timeEntryAggregationService->getAggregatedTimeEntries(
|
||||||
$timeEntriesAggregateQuery,
|
$timeEntriesAggregateQuery,
|
||||||
@@ -355,9 +330,7 @@ class TimeEntryController extends Controller
|
|||||||
$request->getFillGapsInTimeGroups(),
|
$request->getFillGapsInTimeGroups(),
|
||||||
$request->getStart(),
|
$request->getStart(),
|
||||||
$request->getEnd(),
|
$request->getEnd(),
|
||||||
$showBillableRate,
|
$showBillableRate
|
||||||
$roundingType,
|
|
||||||
$roundingMinutes
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -385,7 +358,6 @@ class TimeEntryController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
$this->checkPermission($organization, 'time-entries:view:all');
|
$this->checkPermission($organization, 'time-entries:view:all');
|
||||||
}
|
}
|
||||||
$canAccessPremiumFeatures = $this->canAccessPremiumFeatures($organization);
|
|
||||||
$format = $request->getFormatValue();
|
$format = $request->getFormatValue();
|
||||||
if ($format === ExportFormat::PDF && ! $this->canAccessPremiumFeatures($organization)) {
|
if ($format === ExportFormat::PDF && ! $this->canAccessPremiumFeatures($organization)) {
|
||||||
throw new FeatureIsNotAvailableInFreePlanApiException;
|
throw new FeatureIsNotAvailableInFreePlanApiException;
|
||||||
@@ -397,8 +369,6 @@ class TimeEntryController extends Controller
|
|||||||
$group = $request->getGroup();
|
$group = $request->getGroup();
|
||||||
$subGroup = $request->getSubGroup();
|
$subGroup = $request->getSubGroup();
|
||||||
$timeEntriesAggregateQuery = $this->getTimeEntriesAggregateQuery($organization, $request, $member);
|
$timeEntriesAggregateQuery = $this->getTimeEntriesAggregateQuery($organization, $request, $member);
|
||||||
$roundingType = $canAccessPremiumFeatures ? $request->getRoundingType() : null;
|
|
||||||
$roundingMinutes = $canAccessPremiumFeatures ? $request->getRoundingMinutes() : null;
|
|
||||||
|
|
||||||
$aggregatedData = $timeEntryAggregationService->getAggregatedTimeEntriesWithDescriptions(
|
$aggregatedData = $timeEntryAggregationService->getAggregatedTimeEntriesWithDescriptions(
|
||||||
$timeEntriesAggregateQuery->clone(),
|
$timeEntriesAggregateQuery->clone(),
|
||||||
@@ -409,9 +379,7 @@ class TimeEntryController extends Controller
|
|||||||
false,
|
false,
|
||||||
$request->getStart(),
|
$request->getStart(),
|
||||||
$request->getEnd(),
|
$request->getEnd(),
|
||||||
$showBillableRate,
|
$showBillableRate
|
||||||
$roundingType,
|
|
||||||
$roundingMinutes
|
|
||||||
);
|
);
|
||||||
$dataHistoryChart = $timeEntryAggregationService->getAggregatedTimeEntries(
|
$dataHistoryChart = $timeEntryAggregationService->getAggregatedTimeEntries(
|
||||||
$timeEntriesAggregateQuery->clone(),
|
$timeEntriesAggregateQuery->clone(),
|
||||||
@@ -422,13 +390,10 @@ class TimeEntryController extends Controller
|
|||||||
true,
|
true,
|
||||||
$request->getStart(),
|
$request->getStart(),
|
||||||
$request->getEnd(),
|
$request->getEnd(),
|
||||||
$showBillableRate,
|
$showBillableRate
|
||||||
$roundingType,
|
|
||||||
$roundingMinutes
|
|
||||||
);
|
);
|
||||||
$currency = $organization->currency;
|
$currency = $organization->currency;
|
||||||
$timezone = app(TimezoneService::class)->getTimezoneFromUser($this->user());
|
$timezone = app(TimezoneService::class)->getTimezoneFromUser($this->user());
|
||||||
$localizationService = LocalizationService::forOrganization($organization);
|
|
||||||
|
|
||||||
$filename = 'time-entries-report-'.now()->format('Y-m-d_H-i-s').'.'.$format->getFileExtension();
|
$filename = 'time-entries-report-'.now()->format('Y-m-d_H-i-s').'.'.$format->getFileExtension();
|
||||||
$folderPath = 'exports';
|
$folderPath = 'exports';
|
||||||
@@ -454,12 +419,9 @@ class TimeEntryController extends Controller
|
|||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'group' => $group,
|
'group' => $group,
|
||||||
'subGroup' => $subGroup,
|
'subGroup' => $subGroup,
|
||||||
'timezone' => $timezone,
|
|
||||||
'start' => $request->getStart()->timezone($timezone),
|
'start' => $request->getStart()->timezone($timezone),
|
||||||
'end' => $request->getEnd()->timezone($timezone),
|
'end' => $request->getEnd()->timezone($timezone),
|
||||||
'debug' => $debug,
|
'debug' => $debug,
|
||||||
'localization' => $localizationService,
|
|
||||||
'showBillableRate' => $showBillableRate,
|
|
||||||
]);
|
]);
|
||||||
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-aggregate/pdf-footer.blade.php'));
|
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-aggregate/pdf-footer.blade.php'));
|
||||||
if ($footerViewFile === false) {
|
if ($footerViewFile === false) {
|
||||||
@@ -488,7 +450,7 @@ class TimeEntryController extends Controller
|
|||||||
->putFileAs($folderPath, new File($tempFolder->path($filenameTemp)), $filename);
|
->putFileAs($folderPath, new File($tempFolder->path($filenameTemp)), $filename);
|
||||||
} else {
|
} else {
|
||||||
Excel::store(
|
Excel::store(
|
||||||
new TimeEntriesReportExport($aggregatedData, $format, $currency, $group, $subGroup, $showBillableRate),
|
new TimeEntriesReportExport($aggregatedData, $format, $currency, $group, $subGroup),
|
||||||
$path,
|
$path,
|
||||||
config('filesystems.private'),
|
config('filesystems.private'),
|
||||||
$format->getExportPackageType(),
|
$format->getExportPackageType(),
|
||||||
@@ -507,7 +469,7 @@ class TimeEntryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @return Builder<TimeEntry>
|
* @return Builder<TimeEntry>
|
||||||
*/
|
*/
|
||||||
private function getTimeEntriesAggregateQuery(Organization $organization, TimeEntryAggregateRequest|TimeEntryAggregateExportRequest|TimeEntryIndexExportRequest $request, ?Member $member): Builder
|
private function getTimeEntriesAggregateQuery(Organization $organization, TimeEntryAggregateRequest|TimeEntryAggregateExportRequest $request, ?Member $member): Builder
|
||||||
{
|
{
|
||||||
$timeEntriesQuery = TimeEntry::query()
|
$timeEntriesQuery = TimeEntry::query()
|
||||||
->whereBelongsTo($organization, 'organization');
|
->whereBelongsTo($organization, 'organization');
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Api\V1;
|
|||||||
|
|
||||||
use App\Http\Resources\V1\User\UserResource;
|
use App\Http\Resources\V1\User\UserResource;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
@@ -18,7 +19,7 @@ class UserController extends Controller
|
|||||||
*
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function me(): UserResource
|
public function me(): JsonResource
|
||||||
{
|
{
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,7 @@ class Controller extends BaseController
|
|||||||
/** @var Member|null $member */
|
/** @var Member|null $member */
|
||||||
$member = Member::query()->whereBelongsTo($organization, 'organization')->whereBelongsTo($user, 'user')->first();
|
$member = Member::query()->whereBelongsTo($organization, 'organization')->whereBelongsTo($user, 'user')->first();
|
||||||
if ($member === null) {
|
if ($member === null) {
|
||||||
Log::error('This function should only be called in authenticated context after checking the user is a member of the organization', [
|
Log::error('This function should only be called in authenticated context after checking the user is a member of the organization');
|
||||||
'user' => $user->getKey(),
|
|
||||||
'organization' => $organization->getKey(),
|
|
||||||
]);
|
|
||||||
throw new AuthorizationException;
|
throw new AuthorizationException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Redirect;
|
use Illuminate\Support\Facades\Redirect;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
@@ -19,7 +20,8 @@ class EnsureEmailIsVerified
|
|||||||
{
|
{
|
||||||
if (! app()->isLocal()) {
|
if (! app()->isLocal()) {
|
||||||
if ($request->user() === null ||
|
if ($request->user() === null ||
|
||||||
(! $request->user()->hasVerifiedEmail())) {
|
($request->user() instanceof MustVerifyEmail &&
|
||||||
|
! $request->user()->hasVerifiedEmail())) {
|
||||||
return $request->expectsJson()
|
return $request->expectsJson()
|
||||||
? abort(403, 'Your email address is not verified.')
|
? abort(403, 'Your email address is not verified.')
|
||||||
: Redirect::guest(URL::route($redirectToRoute ?: 'verification.notice'));
|
: Redirect::guest(URL::route($redirectToRoute ?: 'verification.notice'));
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ class HandleInertiaRequests extends Middleware
|
|||||||
public function share(Request $request): array
|
public function share(Request $request): array
|
||||||
{
|
{
|
||||||
$hasBilling = Module::has('Billing') && Module::isEnabled('Billing');
|
$hasBilling = Module::has('Billing') && Module::isEnabled('Billing');
|
||||||
$hasInvoicing = Module::has('Invoicing') && Module::isEnabled('Invoicing');
|
|
||||||
|
|
||||||
/** @var BillingContract $billing */
|
/** @var BillingContract $billing */
|
||||||
$billing = app(BillingContract::class);
|
$billing = app(BillingContract::class);
|
||||||
@@ -49,8 +48,7 @@ class HandleInertiaRequests extends Middleware
|
|||||||
|
|
||||||
return array_merge(parent::share($request), [
|
return array_merge(parent::share($request), [
|
||||||
'has_billing_extension' => $hasBilling,
|
'has_billing_extension' => $hasBilling,
|
||||||
'has_invoicing_extension' => $hasInvoicing,
|
'billing' => $billing !== null && $currentOrganization !== null ? [
|
||||||
'billing' => $currentOrganization !== null ? [
|
|
||||||
'has_subscription' => $billing->hasSubscription($currentOrganization),
|
'has_subscription' => $billing->hasSubscription($currentOrganization),
|
||||||
'has_trial' => $billing->hasTrial($currentOrganization),
|
'has_trial' => $billing->hasTrial($currentOrganization),
|
||||||
'trial_until' => $billing->getTrialUntil($currentOrganization)?->toIso8601ZuluString(),
|
'trial_until' => $billing->getTrialUntil($currentOrganization)?->toIso8601ZuluString(),
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class ShareInertiaData
|
|||||||
{
|
{
|
||||||
/** @var PermissionStore $permissions */
|
/** @var PermissionStore $permissions */
|
||||||
$permissions = app(PermissionStore::class);
|
$permissions = app(PermissionStore::class);
|
||||||
Inertia::share([
|
Inertia::share(array_filter([
|
||||||
'jetstream' => function () use ($request) {
|
'jetstream' => function () use ($request) {
|
||||||
/** @var User|null $user */
|
/** @var User|null $user */
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
@@ -101,7 +101,7 @@ class ShareInertiaData
|
|||||||
return [$key => $bag->messages()];
|
return [$key => $bag->messages()];
|
||||||
})->all();
|
})->all();
|
||||||
},
|
},
|
||||||
]);
|
]));
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\ApiToken;
|
namespace App\Http\Requests\V1\ApiToken;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class ApiTokenStoreRequest extends BaseFormRequest
|
class ApiTokenStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Requests\V1;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class BaseFormRequest extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return list<string>
|
|
||||||
*/
|
|
||||||
protected function moneyRules(bool $bigInt = false): array
|
|
||||||
{
|
|
||||||
$rules = [
|
|
||||||
'integer',
|
|
||||||
'min:0',
|
|
||||||
];
|
|
||||||
if ($bigInt) {
|
|
||||||
$rules[] = 'max:9223372036854775807';
|
|
||||||
} else {
|
|
||||||
$rules[] = 'max:2147483647';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Client;
|
namespace App\Http\Requests\V1\Client;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class ClientIndexRequest extends BaseFormRequest
|
class ClientIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Client;
|
namespace App\Http\Requests\V1\Client;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ClientStoreRequest extends BaseFormRequest
|
class ClientStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Client;
|
namespace App\Http\Requests\V1\Client;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
* @property Client|null $client Client from model binding
|
* @property Client|null $client Client from model binding
|
||||||
*/
|
*/
|
||||||
class ClientUpdateRequest extends BaseFormRequest
|
class ClientUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Import;
|
namespace App\Http\Requests\V1\Import;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class ImportRequest extends BaseFormRequest
|
class ImportRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Invitation;
|
namespace App\Http\Requests\V1\Invitation;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class InvitationIndexRequest extends BaseFormRequest
|
class InvitationIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -5,15 +5,18 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Requests\V1\Invitation;
|
namespace App\Http\Requests\V1\Invitation;
|
||||||
|
|
||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
|
use App\Models\OrganizationInvitation;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class InvitationStoreRequest extends BaseFormRequest
|
class InvitationStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -26,6 +29,10 @@ class InvitationStoreRequest extends BaseFormRequest
|
|||||||
'email' => [
|
'email' => [
|
||||||
'required',
|
'required',
|
||||||
'email',
|
'email',
|
||||||
|
UniqueEloquent::make(OrganizationInvitation::class, 'email', function (Builder $builder): Builder {
|
||||||
|
/** @var Builder<OrganizationInvitation> $builder */
|
||||||
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
|
})->withCustomTranslation('validation.invitation_already_exists'),
|
||||||
],
|
],
|
||||||
'role' => [
|
'role' => [
|
||||||
'required',
|
'required',
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Requests\V1\Member;
|
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property Organization $organization
|
|
||||||
*/
|
|
||||||
class MemberDestroyRequest extends BaseFormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array<string, array<string|ValidationRule>>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'delete_related' => [
|
|
||||||
'string',
|
|
||||||
'in:true,false',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDeleteRelated(): bool
|
|
||||||
{
|
|
||||||
return $this->input('delete_related', 'false') === 'true';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Member;
|
namespace App\Http\Requests\V1\Member;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class MemberIndexRequest extends BaseFormRequest
|
class MemberIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Member;
|
namespace App\Http\Requests\V1\Member;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class MemberMergeIntoRequest extends BaseFormRequest
|
class MemberMergeIntoRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Requests\V1\Member;
|
namespace App\Http\Requests\V1\Member;
|
||||||
|
|
||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class MemberUpdateRequest extends BaseFormRequest
|
class MemberUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -27,12 +27,12 @@ class MemberUpdateRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
Rule::enum(Role::class),
|
Rule::enum(Role::class),
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,98 +4,44 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Organization;
|
namespace App\Http\Requests\V1\Organization;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class OrganizationUpdateRequest extends BaseFormRequest
|
class OrganizationUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string|\Illuminate\Contracts\Validation\Rule>>
|
* @return array<string, array<string|ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => [
|
'name' => [
|
||||||
|
'required',
|
||||||
'string',
|
'string',
|
||||||
'max:255',
|
'max:255',
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
'employees_can_see_billable_rates' => [
|
'employees_can_see_billable_rates' => [
|
||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
'number_format' => [
|
|
||||||
Rule::enum(NumberFormat::class),
|
|
||||||
],
|
|
||||||
'currency_format' => [
|
|
||||||
Rule::enum(CurrencyFormat::class),
|
|
||||||
],
|
|
||||||
'date_format' => [
|
|
||||||
Rule::enum(DateFormat::class),
|
|
||||||
],
|
|
||||||
'interval_format' => [
|
|
||||||
Rule::enum(IntervalFormat::class),
|
|
||||||
],
|
|
||||||
'time_format' => [
|
|
||||||
Rule::enum(TimeFormat::class),
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): ?string
|
|
||||||
{
|
|
||||||
return $this->has('name') ? (string) $this->input('name') : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNumberFormat(): ?NumberFormat
|
|
||||||
{
|
|
||||||
return $this->has('number_format') ? NumberFormat::from($this->input('number_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrencyFormat(): ?CurrencyFormat
|
|
||||||
{
|
|
||||||
return $this->has('currency_format') ? CurrencyFormat::from($this->input('currency_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDateFormat(): ?DateFormat
|
|
||||||
{
|
|
||||||
return $this->has('date_format') ? DateFormat::from($this->input('date_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIntervalFormat(): ?IntervalFormat
|
|
||||||
{
|
|
||||||
return $this->has('interval_format') ? IntervalFormat::from($this->input('interval_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTimeFormat(): ?TimeFormat
|
|
||||||
{
|
|
||||||
return $this->has('time_format') ? TimeFormat::from($this->input('time_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBillableRate(): ?int
|
public function getBillableRate(): ?int
|
||||||
{
|
{
|
||||||
$input = $this->input('billable_rate');
|
$input = $this->input('billable_rate');
|
||||||
|
|
||||||
return $input !== null && $input !== 0 ? (int) $this->input('billable_rate') : null;
|
return $input !== null && $input !== 0 ? (int) $this->input('billable_rate') : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmployeesCanSeeBillableRates(): ?bool
|
|
||||||
{
|
|
||||||
return $this->has('employees_can_see_billable_rates') ? $this->boolean('employees_can_see_billable_rates') : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Project;
|
namespace App\Http\Requests\V1\Project;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class ProjectIndexRequest extends BaseFormRequest
|
class ProjectIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,21 +4,20 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Project;
|
namespace App\Http\Requests\V1\Project;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Rules\ColorRule;
|
use App\Rules\ColorRule;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ProjectStoreRequest extends BaseFormRequest
|
class ProjectStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -28,7 +27,6 @@ class ProjectStoreRequest extends BaseFormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// Name of the project, the name needs to be unique per client and organization
|
|
||||||
'name' => [
|
'name' => [
|
||||||
'required',
|
'required',
|
||||||
'string',
|
'string',
|
||||||
@@ -36,13 +34,7 @@ class ProjectStoreRequest extends BaseFormRequest
|
|||||||
'max:255',
|
'max:255',
|
||||||
UniqueEloquent::make(Project::class, 'name', function (Builder $builder): Builder {
|
UniqueEloquent::make(Project::class, 'name', function (Builder $builder): Builder {
|
||||||
/** @var Builder<Project> $builder */
|
/** @var Builder<Project> $builder */
|
||||||
$clientId = $this->input('client_id');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
if (! is_string($clientId) || ! Str::isUuid($clientId)) {
|
|
||||||
$clientId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization')
|
|
||||||
->where('client_id', $clientId);
|
|
||||||
})->withCustomTranslation('validation.project_name_already_exists'),
|
})->withCustomTranslation('validation.project_name_already_exists'),
|
||||||
],
|
],
|
||||||
'color' => [
|
'color' => [
|
||||||
@@ -55,15 +47,14 @@ class ProjectStoreRequest extends BaseFormRequest
|
|||||||
'required',
|
'required',
|
||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
// ID of the client
|
// ID of the client
|
||||||
'client_id' => [
|
'client_id' => [
|
||||||
'present',
|
|
||||||
'nullable',
|
'nullable',
|
||||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Client> $builder */
|
/** @var Builder<Client> $builder */
|
||||||
|
|||||||
@@ -4,14 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Project;
|
namespace App\Http\Requests\V1\Project;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Rules\ColorRule;
|
use App\Rules\ColorRule;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
|||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
* @property Project|null $project Project from model binding
|
* @property Project|null $project Project from model binding
|
||||||
*/
|
*/
|
||||||
class ProjectUpdateRequest extends BaseFormRequest
|
class ProjectUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -35,13 +34,7 @@ class ProjectUpdateRequest extends BaseFormRequest
|
|||||||
'max:255',
|
'max:255',
|
||||||
UniqueEloquent::make(Project::class, 'name', function (Builder $builder): Builder {
|
UniqueEloquent::make(Project::class, 'name', function (Builder $builder): Builder {
|
||||||
/** @var Builder<Project> $builder */
|
/** @var Builder<Project> $builder */
|
||||||
$clientId = $this->input('client_id');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
if (! is_string($clientId) || ! Str::isUuid($clientId)) {
|
|
||||||
$clientId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization')
|
|
||||||
->where('client_id', $clientId);
|
|
||||||
})->ignore($this->project?->getKey())->withCustomTranslation('validation.project_name_already_exists'),
|
})->ignore($this->project?->getKey())->withCustomTranslation('validation.project_name_already_exists'),
|
||||||
],
|
],
|
||||||
'color' => [
|
'color' => [
|
||||||
@@ -61,18 +54,18 @@ class ProjectUpdateRequest extends BaseFormRequest
|
|||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
'client_id' => [
|
'client_id' => [
|
||||||
'present',
|
|
||||||
'nullable',
|
'nullable',
|
||||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Client> $builder */
|
/** @var Builder<Client> $builder */
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
})->uuid(),
|
})->uuid(),
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge([
|
'billable_rate' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
|
'integer',
|
||||||
|
'min:0',
|
||||||
|
'max:2147483647',
|
||||||
],
|
],
|
||||||
$this->moneyRules()
|
|
||||||
),
|
|
||||||
// Estimated time in seconds
|
// Estimated time in seconds
|
||||||
'estimated_time' => [
|
'estimated_time' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\ProjectMember;
|
namespace App\Http\Requests\V1\ProjectMember;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ProjectMemberStoreRequest extends BaseFormRequest
|
class ProjectMemberStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -31,12 +31,12 @@ class ProjectMemberStoreRequest extends BaseFormRequest
|
|||||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
})->uuid(),
|
})->uuid(),
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\ProjectMember;
|
namespace App\Http\Requests\V1\ProjectMember;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ProjectMemberUpdateRequest extends BaseFormRequest
|
class ProjectMemberUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -21,12 +21,12 @@ class ProjectMemberUpdateRequest extends BaseFormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,19 +6,18 @@ namespace App\Http\Requests\V1\Report;
|
|||||||
|
|
||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Enums\TimeEntryAggregationTypeInterval;
|
use App\Enums\TimeEntryAggregationTypeInterval;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
|
||||||
use App\Enums\Weekday;
|
use App\Enums\Weekday;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\Rule as LegacyValidationRule;
|
use Illuminate\Contracts\Validation\Rule as LegacyValidationRule;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ReportStoreRequest extends BaseFormRequest
|
class ReportStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -41,7 +40,7 @@ class ReportStoreRequest extends BaseFormRequest
|
|||||||
'required',
|
'required',
|
||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
// After this date the report will be automatically set to private (is_public=false) (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// After this date the report will be automatically set to private (is_public=false) (ISO 8601 format, UTC timezone)
|
||||||
'public_until' => [
|
'public_until' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
@@ -129,18 +128,6 @@ class ReportStoreRequest extends BaseFormRequest
|
|||||||
'nullable',
|
'nullable',
|
||||||
'timezone:all',
|
'timezone:all',
|
||||||
],
|
],
|
||||||
// Rounding type defined where the end of each time entry should be rounded to. For example: nearest rounds the end to the nearest x minutes group. Rounding per time entry is activated if `rounding_type` and `rounding_minutes` is not null.
|
|
||||||
'properties.rounding_type' => [
|
|
||||||
'nullable',
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryRoundingType::class),
|
|
||||||
],
|
|
||||||
// Defines the length of the interval that the time entry rounding rounds to.
|
|
||||||
'properties.rounding_minutes' => [
|
|
||||||
'nullable',
|
|
||||||
'numeric',
|
|
||||||
'integer',
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,22 +205,4 @@ class ReportStoreRequest extends BaseFormRequest
|
|||||||
{
|
{
|
||||||
return TimeEntryAggregationTypeInterval::from($this->input('properties.history_group'));
|
return TimeEntryAggregationTypeInterval::from($this->input('properties.history_group'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPropertyRoundingType(): ?TimeEntryRoundingType
|
|
||||||
{
|
|
||||||
if (! $this->has('properties.rounding_type') || $this->input('properties.rounding_type') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TimeEntryRoundingType::from($this->input('properties.rounding_type'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPropertyRoundingMinutes(): ?int
|
|
||||||
{
|
|
||||||
if (! $this->has('properties.rounding_minutes') || $this->input('properties.rounding_minutes') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) $this->input('properties.rounding_minutes');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Report;
|
namespace App\Http\Requests\V1\Report;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ReportUpdateRequest extends BaseFormRequest
|
class ReportUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Tag;
|
namespace App\Http\Requests\V1\Tag;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TagStoreRequest extends BaseFormRequest
|
class TagStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Tag;
|
namespace App\Http\Requests\V1\Tag;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
* @property Tag|null $tag Tag from model binding
|
* @property Tag|null $tag Tag from model binding
|
||||||
*/
|
*/
|
||||||
class TagUpdateRequest extends BaseFormRequest
|
class TagUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Task;
|
namespace App\Http\Requests\V1\Task;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Service\PermissionStore;
|
use App\Service\PermissionStore;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TaskIndexRequest extends BaseFormRequest
|
class TaskIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Task;
|
namespace App\Http\Requests\V1\Task;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TaskStoreRequest extends BaseFormRequest
|
class TaskStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Task;
|
namespace App\Http\Requests\V1\Task;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
* @property Task|null $task Task from model binding
|
* @property Task|null $task Task from model binding
|
||||||
*/
|
*/
|
||||||
class TaskUpdateRequest extends BaseFormRequest
|
class TaskUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ namespace App\Http\Requests\V1\TimeEntry;
|
|||||||
use App\Enums\ExportFormat;
|
use App\Enums\ExportFormat;
|
||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Enums\TimeEntryAggregationTypeInterval;
|
use App\Enums\TimeEntryAggregationTypeInterval;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
@@ -18,6 +16,7 @@ use App\Models\Task;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
@@ -25,7 +24,7 @@ use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
|||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class TimeEntryAggregateExportRequest extends BaseFormRequest
|
class TimeEntryAggregateExportRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -165,18 +164,6 @@ class TimeEntryAggregateExportRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
],
|
],
|
||||||
// Rounding type defined where the end of each time entry should be rounded to. For example: nearest rounds the end to the nearest x minutes group. Rounding per time entry is activated if `rounding_type` and `rounding_minutes` is not null.
|
|
||||||
'rounding_type' => [
|
|
||||||
'nullable',
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryRoundingType::class),
|
|
||||||
],
|
|
||||||
// Defines the length of the interval that the time entry rounding rounds to.
|
|
||||||
'rounding_minutes' => [
|
|
||||||
'nullable',
|
|
||||||
'numeric',
|
|
||||||
'integer',
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,22 +211,4 @@ class TimeEntryAggregateExportRequest extends BaseFormRequest
|
|||||||
{
|
{
|
||||||
return ExportFormat::from($this->validated('format'));
|
return ExportFormat::from($this->validated('format'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRoundingType(): ?TimeEntryRoundingType
|
|
||||||
{
|
|
||||||
if (! $this->has('rounding_type') || $this->validated('rounding_type') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TimeEntryRoundingType::from($this->validated('rounding_type'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRoundingMinutes(): ?int
|
|
||||||
{
|
|
||||||
if (! $this->has('rounding_minutes') || $this->validated('rounding_minutes') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) $this->validated('rounding_minutes');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
@@ -16,6 +14,7 @@ use App\Models\Task;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
@@ -23,7 +22,7 @@ use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
|||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class TimeEntryAggregateRequest extends BaseFormRequest
|
class TimeEntryAggregateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -147,18 +146,6 @@ class TimeEntryAggregateRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
],
|
],
|
||||||
// Rounding type defined where the end of each time entry should be rounded to. For example: nearest rounds the end to the nearest x minutes group. Rounding per time entry is activated if `rounding_type` and `rounding_minutes` is not null.
|
|
||||||
'rounding_type' => [
|
|
||||||
'nullable',
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryRoundingType::class),
|
|
||||||
],
|
|
||||||
// Defines the length of the interval that the time entry rounding rounds to.
|
|
||||||
'rounding_minutes' => [
|
|
||||||
'nullable',
|
|
||||||
'numeric',
|
|
||||||
'integer',
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,22 +173,4 @@ class TimeEntryAggregateRequest extends BaseFormRequest
|
|||||||
{
|
{
|
||||||
return $this->input('end') !== null ? Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $this->input('end'), 'UTC') : null;
|
return $this->input('end') !== null ? Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $this->input('end'), 'UTC') : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRoundingType(): ?TimeEntryRoundingType
|
|
||||||
{
|
|
||||||
if (! $this->has('rounding_type') || $this->validated('rounding_type') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TimeEntryRoundingType::from($this->validated('rounding_type'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRoundingMinutes(): ?int
|
|
||||||
{
|
|
||||||
if (! $this->has('rounding_minutes') || $this->validated('rounding_minutes') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) $this->validated('rounding_minutes');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TimeEntryDestroyMultipleRequest extends BaseFormRequest
|
class TimeEntryDestroyMultipleRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Enums\ExportFormat;
|
use App\Enums\ExportFormat;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
@@ -134,18 +133,6 @@ class TimeEntryIndexExportRequest extends TimeEntryIndexRequest
|
|||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
],
|
],
|
||||||
// Rounding type defined where the end of each time entry should be rounded to. For example: nearest rounds the end to the nearest x minutes group. Rounding per time entry is activated if `rounding_type` and `rounding_minutes` is not null.
|
|
||||||
'rounding_type' => [
|
|
||||||
'nullable',
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryRoundingType::class),
|
|
||||||
],
|
|
||||||
// Defines the length of the interval that the time entry rounding rounds to.
|
|
||||||
'rounding_minutes' => [
|
|
||||||
'nullable',
|
|
||||||
'numeric',
|
|
||||||
'integer',
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,22 +170,4 @@ class TimeEntryIndexExportRequest extends TimeEntryIndexRequest
|
|||||||
{
|
{
|
||||||
return ExportFormat::from($this->validated('format'));
|
return ExportFormat::from($this->validated('format'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRoundingType(): ?TimeEntryRoundingType
|
|
||||||
{
|
|
||||||
if (! $this->has('rounding_type') || $this->validated('rounding_type') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TimeEntryRoundingType::from($this->validated('rounding_type'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRoundingMinutes(): ?int
|
|
||||||
{
|
|
||||||
if (! $this->has('rounding_minutes') || $this->validated('rounding_minutes') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) $this->validated('rounding_minutes');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,29 +4,26 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Enums\TimeEntryRoundingType;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\Rule as RuleContract;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class TimeEntryIndexRequest extends BaseFormRequest
|
class TimeEntryIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string|ValidationRule|RuleContract>>
|
* @return array<string, array<string|ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
@@ -139,18 +136,6 @@ class TimeEntryIndexRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
],
|
],
|
||||||
// Rounding type defined where the end of each time entry should be rounded to. For example: nearest rounds the end to the nearest x minutes group. Rounding per time entry is activated if `rounding_type` and `rounding_minutes` is not null.
|
|
||||||
'rounding_type' => [
|
|
||||||
'nullable',
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryRoundingType::class),
|
|
||||||
],
|
|
||||||
// Defines the length of the interval that the time entry rounding rounds to.
|
|
||||||
'rounding_minutes' => [
|
|
||||||
'nullable',
|
|
||||||
'numeric',
|
|
||||||
'integer',
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,22 +153,4 @@ class TimeEntryIndexRequest extends BaseFormRequest
|
|||||||
{
|
{
|
||||||
return $this->has('offset') ? (int) $this->validated('offset', 0) : 0;
|
return $this->has('offset') ? (int) $this->validated('offset', 0) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRoundingType(): ?TimeEntryRoundingType
|
|
||||||
{
|
|
||||||
if (! $this->has('rounding_type') || $this->validated('rounding_type') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TimeEntryRoundingType::from($this->validated('rounding_type'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRoundingMinutes(): ?int
|
|
||||||
{
|
|
||||||
if (! $this->has('rounding_minutes') || $this->validated('rounding_minutes') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) $this->validated('rounding_minutes');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
@@ -12,12 +11,13 @@ use App\Models\Tag;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TimeEntryStoreRequest extends BaseFormRequest
|
class TimeEntryStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -59,12 +59,12 @@ class TimeEntryStoreRequest extends BaseFormRequest
|
|||||||
->where('project_id', $this->input('project_id'));
|
->where('project_id', $this->input('project_id'));
|
||||||
})->uuid()->withMessage(__('validation.task_belongs_to_project')),
|
})->uuid()->withMessage(__('validation.task_belongs_to_project')),
|
||||||
],
|
],
|
||||||
// Start of time entry (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// Start of time entry (ISO 8601 format, UTC timezone)
|
||||||
'start' => [
|
'start' => [
|
||||||
'required',
|
'required',
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
],
|
],
|
||||||
// End of time entry (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// End of time entry (ISO 8601 format, UTC timezone)
|
||||||
'end' => [
|
'end' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
@@ -12,12 +11,13 @@ use App\Models\Tag;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TimeEntryUpdateMultipleRequest extends BaseFormRequest
|
class TimeEntryUpdateMultipleRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
@@ -12,12 +11,13 @@ use App\Models\Tag;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TimeEntryUpdateRequest extends BaseFormRequest
|
class TimeEntryUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -59,11 +59,11 @@ class TimeEntryUpdateRequest extends BaseFormRequest
|
|||||||
->where('project_id', $this->input('project_id'));
|
->where('project_id', $this->input('project_id'));
|
||||||
})->uuid()->withMessage(__('validation.task_belongs_to_project')),
|
})->uuid()->withMessage(__('validation.task_belongs_to_project')),
|
||||||
],
|
],
|
||||||
// Start of time entry (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// Start of time entry (ISO 8601 format, UTC timezone)
|
||||||
'start' => [
|
'start' => [
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
],
|
],
|
||||||
// End of time entry (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// End of time entry (ISO 8601 format, UTC timezone)
|
||||||
'end' => [
|
'end' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ abstract class BaseResource extends JsonResource
|
|||||||
protected function formatDateTime(?Carbon $carbon): ?string
|
protected function formatDateTime(?Carbon $carbon): ?string
|
||||||
{
|
{
|
||||||
return $carbon?->toIso8601ZuluString();
|
return $carbon?->toIso8601ZuluString();
|
||||||
}
|
|
||||||
|
|
||||||
protected function formatDate(?Carbon $carbon): ?string
|
|
||||||
{
|
|
||||||
return $carbon?->format('Y-m-d');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Resources\V1\Organization;
|
namespace App\Http\Resources\V1\Organization;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Http\Resources\V1\BaseResource;
|
use App\Http\Resources\V1\BaseResource;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Service\CurrencyService;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,8 +34,6 @@ class OrganizationResource extends BaseResource
|
|||||||
*/
|
*/
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
$currencyService = app(CurrencyService::class);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
/** @var string $id ID */
|
/** @var string $id ID */
|
||||||
'id' => $this->resource->id,
|
'id' => $this->resource->id,
|
||||||
@@ -55,18 +47,6 @@ class OrganizationResource extends BaseResource
|
|||||||
'employees_can_see_billable_rates' => $this->resource->employees_can_see_billable_rates,
|
'employees_can_see_billable_rates' => $this->resource->employees_can_see_billable_rates,
|
||||||
/** @var string $currency Currency code (ISO 4217) */
|
/** @var string $currency Currency code (ISO 4217) */
|
||||||
'currency' => $this->resource->currency,
|
'currency' => $this->resource->currency,
|
||||||
/** @var string $currency_symbol Currency symbol */
|
|
||||||
'currency_symbol' => $currencyService->getCurrencySymbol($this->resource->currency),
|
|
||||||
/** @var NumberFormat $number_format Number format */
|
|
||||||
'number_format' => $this->resource->number_format->value,
|
|
||||||
/** @var CurrencyFormat $currency_format Currency format */
|
|
||||||
'currency_format' => $this->resource->currency_format->value,
|
|
||||||
/** @var DateFormat $date_format Date format */
|
|
||||||
'date_format' => $this->resource->date_format->value,
|
|
||||||
/** @var IntervalFormat $interval_format Interval format */
|
|
||||||
'interval_format' => $this->resource->interval_format->value,
|
|
||||||
/** @var TimeFormat $time_format Time format */
|
|
||||||
'time_format' => $this->resource->time_format->value,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,15 @@ use App\Http\Resources\PaginatedResourceCollection;
|
|||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
|
||||||
class ProjectCollection extends ResourceCollection implements PaginatedResourceCollection
|
class ProjectCollection extends ResourceCollection implements PaginatedResourceCollection
|
||||||
{
|
{
|
||||||
private bool $showBillableRates;
|
private bool $showBillableRates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param LengthAwarePaginator<Project> $resource
|
||||||
|
*/
|
||||||
public function __construct($resource, bool $showBillableRates)
|
public function __construct($resource, bool $showBillableRates)
|
||||||
{
|
{
|
||||||
parent::__construct($resource);
|
parent::__construct($resource);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class DetailedReportResource extends BaseResource
|
|||||||
/** @var bool $is_public Whether the report can be accessed via an external link */
|
/** @var bool $is_public Whether the report can be accessed via an external link */
|
||||||
'is_public' => $this->resource->is_public,
|
'is_public' => $this->resource->is_public,
|
||||||
/** @var string|null $public_until Date until the report is public */
|
/** @var string|null $public_until Date until the report is public */
|
||||||
'public_until' => $this->formatDateTime($this->resource->public_until),
|
'public_until' => $this->resource->public_until?->toIso8601ZuluString(),
|
||||||
/** @var string|null $shareable_link Get link to access the report externally, not set if the report is private */
|
/** @var string|null $shareable_link Get link to access the report externally, not set if the report is private */
|
||||||
'shareable_link' => $this->resource->getShareableLink(),
|
'shareable_link' => $this->resource->getShareableLink(),
|
||||||
'properties' => [
|
'properties' => [
|
||||||
@@ -41,9 +41,9 @@ class DetailedReportResource extends BaseResource
|
|||||||
/** @var string $history_group Type of grouping of the historic aggregation (time chart) */
|
/** @var string $history_group Type of grouping of the historic aggregation (time chart) */
|
||||||
'history_group' => $this->resource->properties->historyGroup->value,
|
'history_group' => $this->resource->properties->historyGroup->value,
|
||||||
/** @var string $start Start date of the report */
|
/** @var string $start Start date of the report */
|
||||||
'start' => $this->formatDateTime($this->resource->properties->start),
|
'start' => $this->resource->properties->start->toIso8601ZuluString(),
|
||||||
/** @var string $end End date of the report */
|
/** @var string $end End date of the report */
|
||||||
'end' => $this->formatDateTime($this->resource->properties->end),
|
'end' => $this->resource->properties->end->toIso8601ZuluString(),
|
||||||
/** @var bool|null $active Whether the report is active */
|
/** @var bool|null $active Whether the report is active */
|
||||||
'active' => $this->resource->properties->active,
|
'active' => $this->resource->properties->active,
|
||||||
/** @var array<string>|null $member_ids Filter by multiple member IDs, member IDs are OR combined */
|
/** @var array<string>|null $member_ids Filter by multiple member IDs, member IDs are OR combined */
|
||||||
@@ -58,15 +58,11 @@ class DetailedReportResource extends BaseResource
|
|||||||
'tag_ids' => $this->resource->properties->tagIds?->toArray(),
|
'tag_ids' => $this->resource->properties->tagIds?->toArray(),
|
||||||
/** @var array<string>|null $task_ids Filter by task IDs, task IDs are OR combined */
|
/** @var array<string>|null $task_ids Filter by task IDs, task IDs are OR combined */
|
||||||
'task_ids' => $this->resource->properties->taskIds?->toArray(),
|
'task_ids' => $this->resource->properties->taskIds?->toArray(),
|
||||||
/** @var string|null $rounding_type Rounding type for time entries */
|
|
||||||
'rounding_type' => $this->resource->properties->roundingType?->value,
|
|
||||||
/** @var int|null $rounding_minutes Rounding minutes for time entries */
|
|
||||||
'rounding_minutes' => $this->resource->properties->roundingMinutes,
|
|
||||||
],
|
],
|
||||||
/** @var string $created_at Date when the report was created */
|
/** @var string $created_at Date when the report was created */
|
||||||
'created_at' => $this->formatDateTime($this->resource->created_at),
|
'created_at' => $this->resource->created_at?->toIso8601ZuluString(),
|
||||||
/** @var string $updated_at Date when the report was last updated */
|
/** @var string $updated_at Date when the report was last updated */
|
||||||
'updated_at' => $this->formatDateTime($this->resource->updated_at),
|
'updated_at' => $this->resource->updated_at?->toIso8601ZuluString(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Resources\V1\Report;
|
namespace App\Http\Resources\V1\Report;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Http\Resources\V1\BaseResource;
|
use App\Http\Resources\V1\BaseResource;
|
||||||
use App\Models\Report;
|
use App\Models\Report;
|
||||||
use App\Service\CurrencyService;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,29 +64,15 @@ class DetailedWithDataReportResource extends BaseResource
|
|||||||
*/
|
*/
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
$currencyService = app(CurrencyService::class);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
/** @var string $name Name */
|
/** @var string $name Name */
|
||||||
'name' => $this->resource->name,
|
'name' => $this->resource->name,
|
||||||
/** @var string|null $email Description */
|
/** @var string|null $email Description */
|
||||||
'description' => $this->resource->description,
|
'description' => $this->resource->description,
|
||||||
/** @var string|null $public_until Date until the report is public */
|
/** @var string|null $public_until Date until the report is public */
|
||||||
'public_until' => $this->formatDateTime($this->resource->public_until),
|
'public_until' => $this->resource->public_until?->toIso8601ZuluString(),
|
||||||
/** @var string $currency Currency code (ISO 4217) */
|
/** @var string $currency Currency code (ISO 4217) */
|
||||||
'currency' => $this->resource->organization->currency,
|
'currency' => $this->resource->organization->currency,
|
||||||
/** @var NumberFormat $number_format Number format */
|
|
||||||
'number_format' => $this->resource->organization->number_format->value,
|
|
||||||
/** @var CurrencyFormat $currency_format Currency format */
|
|
||||||
'currency_format' => $this->resource->organization->currency_format->value,
|
|
||||||
/** @var string $currency_symbol Currency symbol */
|
|
||||||
'currency_symbol' => $currencyService->getCurrencySymbol($this->resource->organization->currency),
|
|
||||||
/** @var DateFormat $date_format Date format */
|
|
||||||
'date_format' => $this->resource->organization->date_format->value,
|
|
||||||
/** @var IntervalFormat $interval_format Interval format */
|
|
||||||
'interval_format' => $this->resource->organization->interval_format->value,
|
|
||||||
/** @var TimeFormat $time_format Time format */
|
|
||||||
'time_format' => $this->resource->organization->time_format->value,
|
|
||||||
'properties' => [
|
'properties' => [
|
||||||
/** @var string $group Type of first grouping */
|
/** @var string $group Type of first grouping */
|
||||||
'group' => $this->resource->properties->group->value,
|
'group' => $this->resource->properties->group->value,
|
||||||
@@ -101,9 +81,9 @@ class DetailedWithDataReportResource extends BaseResource
|
|||||||
/** @var string $history_group Type of grouping of the historic aggregation (time chart) */
|
/** @var string $history_group Type of grouping of the historic aggregation (time chart) */
|
||||||
'history_group' => $this->resource->properties->historyGroup->value,
|
'history_group' => $this->resource->properties->historyGroup->value,
|
||||||
/** @var string $start Start date of the report */
|
/** @var string $start Start date of the report */
|
||||||
'start' => $this->formatDateTime($this->resource->properties->start),
|
'start' => $this->resource->properties->start->toIso8601ZuluString(),
|
||||||
/** @var string $end End date of the report */
|
/** @var string $end End date of the report */
|
||||||
'end' => $this->formatDateTime($this->resource->properties->end),
|
'end' => $this->resource->properties->end->toIso8601ZuluString(),
|
||||||
],
|
],
|
||||||
/** @var array{
|
/** @var array{
|
||||||
* grouped_type: string|null,
|
* grouped_type: string|null,
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ class ReportResource extends BaseResource
|
|||||||
/** @var bool $is_public Whether the report can be accessed via an external link */
|
/** @var bool $is_public Whether the report can be accessed via an external link */
|
||||||
'is_public' => $this->resource->is_public,
|
'is_public' => $this->resource->is_public,
|
||||||
/** @var string|null $public_until Date until the report is public */
|
/** @var string|null $public_until Date until the report is public */
|
||||||
'public_until' => $this->formatDateTime($this->resource->public_until),
|
'public_until' => $this->resource->public_until?->toIso8601ZuluString(),
|
||||||
/** @var string|null $shareable_link Get link to access the report externally, not set if the report is private */
|
/** @var string|null $shareable_link Get link to access the report externally, not set if the report is private */
|
||||||
'shareable_link' => $this->resource->getShareableLink(),
|
'shareable_link' => $this->resource->getShareableLink(),
|
||||||
/** @var string $created_at Date when the report was created */
|
/** @var string $created_at Date when the report was created */
|
||||||
'created_at' => $this->formatDateTime($this->resource->created_at),
|
'created_at' => $this->resource->created_at?->toIso8601ZuluString(),
|
||||||
/** @var string $updated_at Date when the report was last updated */
|
/** @var string $updated_at Date when the report was last updated */
|
||||||
'updated_at' => $this->formatDateTime($this->resource->updated_at),
|
'updated_at' => $this->resource->updated_at?->toIso8601ZuluString(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Mail;
|
|
||||||
|
|
||||||
use App\Models\Passport\Token;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Mail\Mailable;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\URL;
|
|
||||||
|
|
||||||
class AuthApiTokenExpirationReminderMail extends Mailable
|
|
||||||
{
|
|
||||||
use Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public Token $token;
|
|
||||||
|
|
||||||
public User $user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new message instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(Token $token, User $user)
|
|
||||||
{
|
|
||||||
$this->token = $token;
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the message.
|
|
||||||
*/
|
|
||||||
public function build(): self
|
|
||||||
{
|
|
||||||
return $this->markdown('emails.auth-api-expiration-reminder', [
|
|
||||||
'profileUrl' => URL::to('user/profile'),
|
|
||||||
'tokenName' => $this->token->name,
|
|
||||||
])
|
|
||||||
->subject(__('Your API token will expire in 7 days!'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Mail;
|
|
||||||
|
|
||||||
use App\Models\Passport\Token;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Mail\Mailable;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\URL;
|
|
||||||
|
|
||||||
class AuthApiTokenExpiredMail extends Mailable
|
|
||||||
{
|
|
||||||
use Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public Token $token;
|
|
||||||
|
|
||||||
public User $user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new message instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(Token $token, User $user)
|
|
||||||
{
|
|
||||||
$this->token = $token;
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the message.
|
|
||||||
*/
|
|
||||||
public function build(): self
|
|
||||||
{
|
|
||||||
return $this->markdown('emails.auth-api-token-expired', [
|
|
||||||
'profileUrl' => URL::to('user/profile'),
|
|
||||||
'tokenName' => $this->token->name,
|
|
||||||
])
|
|
||||||
->subject(__('Your API token has expired!'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,8 +16,8 @@ use OwenIt\Auditing\Models\Audit as PackageAuditModel;
|
|||||||
* @property string $event
|
* @property string $event
|
||||||
* @property string $auditable_type
|
* @property string $auditable_type
|
||||||
* @property string $auditable_id
|
* @property string $auditable_id
|
||||||
* @property array<string, mixed>|null $old_values
|
* @property array|null $old_values
|
||||||
* @property array<string, mixed>|null $new_values
|
* @property array|null $new_values
|
||||||
* @property string|null $url
|
* @property string|null $url
|
||||||
* @property string|null $ip_address
|
* @property string|null $ip_address
|
||||||
* @property string|null $user_agent
|
* @property string|null $user_agent
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class Client extends Model implements AuditableContract
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<Organization, $this>
|
* @return BelongsTo<Organization, Client>
|
||||||
*/
|
*/
|
||||||
public function organization(): BelongsTo
|
public function organization(): BelongsTo
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@ class Client extends Model implements AuditableContract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return HasMany<Project, $this>
|
* @return HasMany<Project>
|
||||||
*/
|
*/
|
||||||
public function projects(): HasMany
|
public function projects(): HasMany
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
* @property Carbon|null $updated_at
|
* @property Carbon|null $updated_at
|
||||||
* @property-read Organization $organization
|
* @property-read Organization $organization
|
||||||
* @property-read User $user
|
* @property-read User $user
|
||||||
* @property-read Collection<int, ProjectMember> $projectMembers
|
* @property-read Collection<ProjectMember> $projectMembers
|
||||||
* @property-read Collection<int, TimeEntry> $timeEntries
|
* @property-read Collection<TimeEntry> $timeEntries
|
||||||
*
|
*
|
||||||
* @method static MemberFactory factory()
|
* @method static MemberFactory factory()
|
||||||
*/
|
*/
|
||||||
@@ -47,7 +47,7 @@ class Member extends JetstreamMembership implements AuditableContract
|
|||||||
protected $table = 'members';
|
protected $table = 'members';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<User, $this>
|
* @return BelongsTo<User, Member>
|
||||||
*/
|
*/
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@ class Member extends JetstreamMembership implements AuditableContract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<Organization, $this>
|
* @return BelongsTo<Organization, Member>
|
||||||
*/
|
*/
|
||||||
public function organization(): BelongsTo
|
public function organization(): BelongsTo
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ class Member extends JetstreamMembership implements AuditableContract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return HasMany<TimeEntry, $this>
|
* @return HasMany<TimeEntry>
|
||||||
*/
|
*/
|
||||||
public function timeEntries(): HasMany
|
public function timeEntries(): HasMany
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,7 @@ class Member extends JetstreamMembership implements AuditableContract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return HasMany<ProjectMember, $this>
|
* @return HasMany<ProjectMember>
|
||||||
*/
|
*/
|
||||||
public function projectMembers(): HasMany
|
public function projectMembers(): HasMany
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,11 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Models\Concerns\CustomAuditable;
|
use App\Models\Concerns\CustomAuditable;
|
||||||
use App\Models\Concerns\HasUuids;
|
use App\Models\Concerns\HasUuids;
|
||||||
use Database\Factories\OrganizationFactory;
|
use Database\Factories\OrganizationFactory;
|
||||||
@@ -18,12 +13,12 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Laravel\Jetstream\Events\TeamCreated;
|
use Laravel\Jetstream\Events\TeamCreated;
|
||||||
use Laravel\Jetstream\Events\TeamDeleted;
|
use Laravel\Jetstream\Events\TeamDeleted;
|
||||||
use Laravel\Jetstream\Events\TeamUpdated;
|
use Laravel\Jetstream\Events\TeamUpdated;
|
||||||
|
use Laravel\Jetstream\Jetstream;
|
||||||
use Laravel\Jetstream\Team as JetstreamTeam;
|
use Laravel\Jetstream\Team as JetstreamTeam;
|
||||||
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
||||||
|
|
||||||
@@ -42,13 +37,8 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
* @property Collection<int, User> $realUsers
|
* @property Collection<int, User> $realUsers
|
||||||
* @property-read Collection<int, OrganizationInvitation> $teamInvitations
|
* @property-read Collection<int, OrganizationInvitation> $teamInvitations
|
||||||
* @property Member $membership
|
* @property Member $membership
|
||||||
* @property NumberFormat $number_format
|
|
||||||
* @property CurrencyFormat $currency_format
|
|
||||||
* @property DateFormat $date_format
|
|
||||||
* @property IntervalFormat $interval_format
|
|
||||||
* @property TimeFormat $time_format
|
|
||||||
*
|
*
|
||||||
* @method HasMany<OrganizationInvitation, $this> teamInvitations()
|
* @method HasMany<OrganizationInvitation> teamInvitations()
|
||||||
* @method static OrganizationFactory factory()
|
* @method static OrganizationFactory factory()
|
||||||
*/
|
*/
|
||||||
class Organization extends JetstreamTeam implements AuditableContract
|
class Organization extends JetstreamTeam implements AuditableContract
|
||||||
@@ -70,17 +60,12 @@ class Organization extends JetstreamTeam implements AuditableContract
|
|||||||
'personal_team' => 'boolean',
|
'personal_team' => 'boolean',
|
||||||
'currency' => 'string',
|
'currency' => 'string',
|
||||||
'employees_can_see_billable_rates' => 'boolean',
|
'employees_can_see_billable_rates' => 'boolean',
|
||||||
'number_format' => NumberFormat::class,
|
|
||||||
'currency_format' => CurrencyFormat::class,
|
|
||||||
'date_format' => DateFormat::class,
|
|
||||||
'interval_format' => IntervalFormat::class,
|
|
||||||
'time_format' => TimeFormat::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*
|
*
|
||||||
* @var list<string>
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
@@ -104,6 +89,7 @@ class Organization extends JetstreamTeam implements AuditableContract
|
|||||||
* @var array<string, mixed>
|
* @var array<string, mixed>
|
||||||
*/
|
*/
|
||||||
protected $attributes = [
|
protected $attributes = [
|
||||||
|
'currency' => 'EUR',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,7 +112,7 @@ class Organization extends JetstreamTeam implements AuditableContract
|
|||||||
/**
|
/**
|
||||||
* Get all the users that belong to the team.
|
* Get all the users that belong to the team.
|
||||||
*
|
*
|
||||||
* @return BelongsToMany<User, $this, Pivot, 'membership'>
|
* @return BelongsToMany<User>
|
||||||
*/
|
*/
|
||||||
public function users(): BelongsToMany
|
public function users(): BelongsToMany
|
||||||
{
|
{
|
||||||
@@ -143,7 +129,7 @@ class Organization extends JetstreamTeam implements AuditableContract
|
|||||||
/**
|
/**
|
||||||
* Get the owner of the team.
|
* Get the owner of the team.
|
||||||
*
|
*
|
||||||
* @return BelongsTo<User, $this>
|
* @return BelongsTo<User, Organization>
|
||||||
*/
|
*/
|
||||||
public function owner(): BelongsTo
|
public function owner(): BelongsTo
|
||||||
{
|
{
|
||||||
@@ -151,7 +137,7 @@ class Organization extends JetstreamTeam implements AuditableContract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return HasMany<Member, $this>
|
* @return HasMany<Member>
|
||||||
*/
|
*/
|
||||||
public function members(): HasMany
|
public function members(): HasMany
|
||||||
{
|
{
|
||||||
@@ -159,7 +145,7 @@ class Organization extends JetstreamTeam implements AuditableContract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsToMany<User, $this, Pivot, 'membership'>
|
* @return BelongsToMany<User>
|
||||||
*/
|
*/
|
||||||
public function realUsers(): BelongsToMany
|
public function realUsers(): BelongsToMany
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class OrganizationInvitation extends JetstreamTeamInvitation implements Auditabl
|
|||||||
/**
|
/**
|
||||||
* Get the organization that the invitation belongs to.
|
* Get the organization that the invitation belongs to.
|
||||||
*
|
*
|
||||||
* @return BelongsTo<Organization, $this>
|
* @return BelongsTo<Organization, OrganizationInvitation>
|
||||||
*/
|
*/
|
||||||
public function organization(): BelongsTo
|
public function organization(): BelongsTo
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ class OrganizationInvitation extends JetstreamTeamInvitation implements Auditabl
|
|||||||
/**
|
/**
|
||||||
* Get the organization that the invitation belongs to.
|
* Get the organization that the invitation belongs to.
|
||||||
*
|
*
|
||||||
* @return BelongsTo<Organization, $this>
|
* @return BelongsTo<Organization, OrganizationInvitation>
|
||||||
*/
|
*/
|
||||||
public function team(): BelongsTo
|
public function team(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,26 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Models\Passport;
|
namespace App\Models\Passport;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use Laravel\Passport\AuthCode as PassportAuthCode;
|
use Laravel\Passport\AuthCode as PassportAuthCode;
|
||||||
|
|
||||||
/**
|
class AuthCode extends PassportAuthCode {}
|
||||||
* @property string $id
|
|
||||||
* @property string $user_id
|
|
||||||
* @property string $client_id
|
|
||||||
* @property string|null $scopes
|
|
||||||
* @property bool $revoked
|
|
||||||
* @property Carbon $expires_at
|
|
||||||
*/
|
|
||||||
class AuthCode extends PassportAuthCode
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return BelongsTo<User, $this>
|
|
||||||
*/
|
|
||||||
public function user(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(User::class, 'user_id');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,36 +5,22 @@ declare(strict_types=1);
|
|||||||
namespace App\Models\Passport;
|
namespace App\Models\Passport;
|
||||||
|
|
||||||
use Database\Factories\Passport\ClientFactory;
|
use Database\Factories\Passport\ClientFactory;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use Laravel\Passport\Client as PassportClient;
|
use Laravel\Passport\Client as PassportClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property string $id
|
* @property string $id
|
||||||
* @property string|null $owner_id
|
* @property string|null $user_id
|
||||||
* @property string|null $owner_type
|
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string|null $secret
|
* @property string|null $secret
|
||||||
* @property string|null $provider
|
* @property string|null $provider
|
||||||
* @property array<string> $grant_types
|
* @property string $redirect
|
||||||
* @property array<string> $redirect_uris
|
* @property bool $personal_access_client
|
||||||
* @property Carbon|null $created_at
|
* @property bool $password_client
|
||||||
* @property Carbon|null $updated_at
|
|
||||||
* @property bool $revoked
|
* @property bool $revoked
|
||||||
*/
|
*/
|
||||||
class Client extends PassportClient
|
class Client extends PassportClient
|
||||||
{
|
{
|
||||||
/** @use HasFactory<ClientFactory> */
|
/** @use HasFactory<ClientFactory> */
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new factory instance for the model.
|
|
||||||
*
|
|
||||||
* @return ClientFactory
|
|
||||||
*/
|
|
||||||
protected static function newFactory(): Factory
|
|
||||||
{
|
|
||||||
return ClientFactory::new();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
9
app/Models/Passport/PersonalAccessClient.php
Normal file
9
app/Models/Passport/PersonalAccessClient.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models\Passport;
|
||||||
|
|
||||||
|
use Laravel\Passport\PersonalAccessClient as PassportPersonalAccessClient;
|
||||||
|
|
||||||
|
class PersonalAccessClient extends PassportPersonalAccessClient {}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user