Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.3 #1940

Merged
merged 155 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
2617ca5
refactor: try import
FredPeal Aug 28, 2024
b8b9aa8
feat: import from mapper
FredPeal Aug 29, 2024
eb9f408
fix: filesystem service
FredPeal Aug 29, 2024
9c8144b
refactor: feedback
FredPeal Aug 29, 2024
343270a
Apply fixes from StyleCI
StyleCIBot Aug 30, 2024
e5d91eb
Merge pull request #1878 from bakaphp/analysis-a6AMn0
kaioken Aug 30, 2024
a35f5f0
merge with dev
kaioken Aug 30, 2024
5b68444
refact: methos
kaioken Aug 31, 2024
aa8242e
Merge branch 'development' into import-csv-agent-vault
kaioken Aug 31, 2024
1559828
fix: formatting
kaioken Aug 31, 2024
1bf962b
feat: add index
kaioken Aug 31, 2024
4d30709
refact: create mapping
kaioken Sep 1, 2024
cef63f1
refact: create mapping
kaioken Sep 1, 2024
461989b
refact: create mapping
kaioken Sep 1, 2024
a63bc1a
refact: create mapping
kaioken Sep 1, 2024
7b5b014
refact: create mapping
kaioken Sep 1, 2024
43f0ab2
refact: create mapping
kaioken Sep 1, 2024
378fefe
refact: create mapping
kaioken Sep 1, 2024
960df7f
refact: create mapping
kaioken Sep 1, 2024
2e9a1d0
refact: create mapping
kaioken Sep 1, 2024
61f05d8
Merge pull request #1886 from bakaphp/import-csv-mapper-v2
kaioken Sep 1, 2024
cb64272
refactor: read csv
FredPeal Sep 2, 2024
d077c3a
refactor: mapper imported
FredPeal Sep 3, 2024
abe9c7f
refactor: move csv to private folders
FredPeal Sep 4, 2024
e840346
Merge branch 'development' of github.com:bakaphp/kanvas-ecosystem-api…
FredPeal Sep 4, 2024
38d764c
refactor: test
FredPeal Sep 5, 2024
d543aa7
refactor: default values for browse_fields
FredPeal Sep 5, 2024
d4d9eac
fix: url image and warehouses
FredPeal Sep 5, 2024
2051526
refactor: add employment to people input
FredPeal Sep 6, 2024
8a2e3a2
refactor: use observers
FredPeal Sep 6, 2024
a47ceaf
refactor: delete migrations
FredPeal Sep 6, 2024
547931c
hotfix- search by tag
kaioken Sep 6, 2024
600d3d5
fix: not found people
kaioken Sep 6, 2024
06e0e37
use match
FredPeal Sep 6, 2024
4f2f474
Merge pull request #1874 from bakaphp/import-csv-agent-vault
kaioken Sep 6, 2024
b7a01ae
Refact: hotfix
kaioken Sep 6, 2024
82f76dc
Refact: hotfix
kaioken Sep 6, 2024
b168e75
Refact: hotfix
kaioken Sep 6, 2024
7b4b32a
refact: shopify image error
kaioken Sep 6, 2024
4b0d090
refact: shopify image error
kaioken Sep 6, 2024
9a2ea55
Merge pull request #1925 from bakaphp/refact-migration-hotfix
kaioken Sep 6, 2024
cd06a4e
refact: company crud permissions
kaioken Sep 6, 2024
302f502
Merge pull request #1926 from bakaphp/refact-company-crud-permissions
kaioken Sep 6, 2024
bf2fd8a
updte composer
kaioken Sep 6, 2024
3bb2ed4
Merge pull request #1927 from bakaphp/refact-company-crud-permissions
kaioken Sep 6, 2024
9c8541d
refact: company crud permissions
kaioken Sep 6, 2024
5a35bdf
Merge pull request #1928 from bakaphp/refact-company-crud-permissions
kaioken Sep 6, 2024
058bb0c
hotfix: delete user process
kaioken Sep 7, 2024
520165e
Merge branch 'development' of github.com:bakaphp/kanvas-ecosystem-api…
kaioken Sep 7, 2024
bcefde9
refact: custom field optimization
kaioken Sep 7, 2024
751b7bf
refact: custom field optimization
kaioken Sep 7, 2024
3f7bd72
Merge pull request #1929 from bakaphp/refact-custom-field-optimization
kaioken Sep 7, 2024
180b8f6
Merge pull request #1932 from bakaphp/refact-custom-field-optimization-2
kaioken Sep 7, 2024
75c5dbe
Merge pull request #1933 from bakaphp/refact-custom-field-optimization-2
kaioken Sep 7, 2024
892dfdb
Merge pull request #1935 from bakaphp/refact-custom-field-optimization-2
kaioken Sep 8, 2024
c55ae9d
refactor: create or update
FredPeal Sep 8, 2024
f2bb49a
hotfix: filesystem importer
kaioken Sep 8, 2024
2f4831f
refact: product structure
kaioken Sep 8, 2024
886e0b5
refact: product structure
kaioken Sep 8, 2024
e196cc2
refact: product structure
kaioken Sep 8, 2024
e3f028b
refact: product structure
kaioken Sep 8, 2024
502eba9
refact: product structure
kaioken Sep 9, 2024
63eca2c
fix: test
kaioken Sep 9, 2024
9ba40cf
refat: file import status
kaioken Sep 9, 2024
2c93ac1
refat: file import status
kaioken Sep 9, 2024
6906355
refat: file import status
kaioken Sep 9, 2024
a2e44e8
fix: typo
kaioken Sep 9, 2024
f07ca33
fix: typo
kaioken Sep 9, 2024
8cc2ccb
fix: typo
kaioken Sep 9, 2024
2f4dcd5
fix: type
kaioken Sep 9, 2024
05bdf9b
Merge pull request #1937 from bakaphp/hotfixes-filesystem-importer
kaioken Sep 9, 2024
ffb22a7
Merge pull request #1938 from bakaphp/hotfix-product-price
kaioken Sep 9, 2024
a91c3d5
Merge pull request #1941 from bakaphp/hotfix-product-price
kaioken Sep 9, 2024
a766e03
feat: admin app setting
kaioken Sep 9, 2024
673a601
feat: add test
kaioken Sep 9, 2024
30dae2e
feat: add test
kaioken Sep 9, 2024
cdd0593
feat: add test
kaioken Sep 9, 2024
36bf693
Merge pull request #1943 from bakaphp/feat-admin-app-setting
kaioken Sep 9, 2024
c14686e
hotfix: user inteaction cache
kaioken Sep 9, 2024
3f27470
Merge pull request #1944 from bakaphp/feat-admin-app-setting
kaioken Sep 9, 2024
74843ef
add attachFileToMessage mutation
rwhite27 Sep 9, 2024
93df615
build(deps-dev): bump phpunit/phpunit from 11.3.3 to 11.3.4
dependabot[bot] Sep 9, 2024
b87ded1
build(deps-dev): bump phpstan/phpstan from 1.12.2 to 1.12.3
dependabot[bot] Sep 9, 2024
83dda01
hotfix: attributes type app
kaioken Sep 9, 2024
e61c38f
Merge pull request #1948 from bakaphp/hotfix-attributes-type-app
kaioken Sep 9, 2024
e5a011b
Merge pull request #1946 from bakaphp/dependabot/composer/phpunit/php…
kaioken Sep 9, 2024
91822a1
Merge pull request #1947 from bakaphp/dependabot/composer/phpstan/php…
kaioken Sep 9, 2024
237b4f6
hotfix: company users properties
kaioken Sep 10, 2024
c0db76d
Merge pull request #1949 from bakaphp/hotfix-company-users-properties
kaioken Sep 10, 2024
9204f4f
refact: app delete app settings
kaioken Sep 10, 2024
8739489
Merge pull request #1950 from bakaphp/hotfix-delete-app-settings
kaioken Sep 10, 2024
e9b9634
feat: get company setting
kaioken Sep 10, 2024
170e7af
Merge pull request #1951 from bakaphp/hotfix-delete-app-settings
kaioken Sep 10, 2024
1481383
refactor: check position
FredPeal Sep 10, 2024
aa1eb37
Merge pull request #1924 from bakaphp/KCT-174
kaioken Sep 10, 2024
8a7b61c
add message user validation
rwhite27 Sep 10, 2024
6d87ddc
fix format
rwhite27 Sep 10, 2024
e3006ba
Merge pull request #1945 from bakaphp/MK-2988-attach-file-message
rwhite27 Sep 10, 2024
d2d3f8a
refact: unique jobs
kaioken Sep 10, 2024
491e48e
refact: unique jobs
kaioken Sep 10, 2024
01961ec
Merge pull request #1952 from bakaphp/hotfix-unique-clear-cache-job
kaioken Sep 10, 2024
98db4e5
Rrefact: avoid duplicate tags
kaioken Sep 10, 2024
a8fb088
Refact: fix duplicate tags
kaioken Sep 10, 2024
3fb78aa
Merge pull request #1954 from bakaphp/hotfix-unique-clear-cache-job
kaioken Sep 10, 2024
f990d91
refact: check if it already exsit
kaioken Sep 10, 2024
b54182a
Merge pull request #1956 from bakaphp/hotfix-unique-clear-cache-job
kaioken Sep 10, 2024
b846673
Refact: fix order by
kaioken Sep 10, 2024
83e2103
Merge pull request #1957 from bakaphp/hotfix-company-users-order-by
kaioken Sep 10, 2024
dd2d80c
build(deps): bump spatie/laravel-data from 4.8.2 to 4.9.0
dependabot[bot] Sep 10, 2024
7d11d9e
Merge pull request #1959 from bakaphp/dependabot/composer/spatie/lara…
kaioken Sep 11, 2024
89bc9b9
feat: add total childer to msg
kaioken Sep 11, 2024
84b6059
Merge pull request #1960 from bakaphp/feat-total-message-child
kaioken Sep 11, 2024
1e95b28
Add files to Message structure
rwhite27 Sep 11, 2024
b4dca1d
Merge pull request #1961 from bakaphp/MK-2988-attach-file-message
rwhite27 Sep 11, 2024
41994a3
feat: task list by id
kaioken Sep 11, 2024
4dd95e0
feat: add new graphql query
kaioken Sep 11, 2024
81140ab
Merge pull request #1962 from bakaphp/feat-list-task-by-id
kaioken Sep 11, 2024
a6fca2d
build(deps): bump laravel/framework from 11.22.0 to 11.23.2
dependabot[bot] Sep 11, 2024
d1aeb8a
build(deps): bump laravel/octane from 2.5.4 to 2.5.5
dependabot[bot] Sep 11, 2024
0f439eb
build(deps): bump laravel/scout from 10.11.2 to 10.11.3
dependabot[bot] Sep 11, 2024
05a9c42
add disconnect from database listener
rwhite27 Sep 12, 2024
6731a1b
set sticky to false for all database connections
rwhite27 Sep 12, 2024
894337e
Merge pull request #1967 from bakaphp/add-database-pooling
rwhite27 Sep 12, 2024
b6c3c49
Merge pull request #1964 from bakaphp/dependabot/composer/laravel/oct…
kaioken Sep 12, 2024
231c1ed
Merge pull request #1965 from bakaphp/dependabot/composer/laravel/sco…
kaioken Sep 12, 2024
0bb2950
Merge pull request #1963 from bakaphp/dependabot/composer/laravel/fra…
kaioken Sep 12, 2024
43f7257
refact: test
kaioken Sep 12, 2024
3886271
Merge pull request #1968 from bakaphp/feat-list-task-by-id
kaioken Sep 12, 2024
19c0341
refact: increment
kaioken Sep 12, 2024
6bf1c35
hotfx: message tags
kaioken Sep 12, 2024
10f058f
refact: secure cookie
kaioken Sep 12, 2024
4ad09c3
hotfx: message tags
kaioken Sep 12, 2024
8b2615f
refact: event
kaioken Sep 12, 2024
0b55222
Merge pull request #1969 from bakaphp/hotfix-pusher-data-task
kaioken Sep 12, 2024
cc3912d
hotfix: implementation
kaioken Sep 12, 2024
3ef56bd
Merge pull request #1970 from bakaphp/hotfix-pusher-data-task
kaioken Sep 12, 2024
e8ec975
hotfix: implementation
kaioken Sep 12, 2024
0c9eda6
Merge pull request #1972 from bakaphp/hotfix-pusher-data-task
kaioken Sep 12, 2024
4b81a5b
build(deps): bump stripe/stripe-php from 15.8.0 to 15.9.0
dependabot[bot] Sep 12, 2024
dadbbf1
build(deps): bump laravel/framework from 11.23.2 to 11.23.4
dependabot[bot] Sep 12, 2024
a1d3c9a
refact: you cant change attribute type right now
kaioken Sep 12, 2024
a2e7886
refact: you cant change attribute type right now
kaioken Sep 12, 2024
49d7230
Merge pull request #1975 from bakaphp/dependabot/composer/laravel/fra…
kaioken Sep 12, 2024
233c7df
Merge pull request #1974 from bakaphp/dependabot/composer/stripe/stri…
kaioken Sep 12, 2024
19cb770
feat: upload file mutation trait
kaioken Sep 13, 2024
34aa2c7
Merge pull request #1977 from bakaphp/feat-upload-file-mutation-trait
kaioken Sep 13, 2024
be2c65a
refact: upload ecosystem files
kaioken Sep 13, 2024
6e21123
build(deps): bump laravel/framework from 11.23.4 to 11.23.5
dependabot[bot] Sep 13, 2024
4ef5087
build(deps-dev): bump phpunit/phpunit from 11.3.4 to 11.3.5
dependabot[bot] Sep 13, 2024
a87f73a
refact: upload ecosystem files
kaioken Sep 13, 2024
64fccaf
refact: upload ecosystem files
kaioken Sep 13, 2024
a29dfab
refact: upload ecosystem files
kaioken Sep 13, 2024
c77ae2b
Merge pull request #1978 from bakaphp/feat-upload-ecosystem-files
kaioken Sep 13, 2024
8eb0c7e
Merge pull request #1979 from bakaphp/dependabot/composer/laravel/fra…
kaioken Sep 13, 2024
2bec0e0
Merge pull request #1980 from bakaphp/dependabot/composer/phpunit/php…
kaioken Sep 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public function getLeadTaskItems(
$lead = Lead::getByIdFromCompanyApp($args['lead_id'], $company, $app);
$leadId = $lead->getId();

return TaskEngagementItemRepository::getLeadsTaskItems($lead);
return TaskEngagementItemRepository::getLeadsTaskItems($lead, (int) ($args['task_list_id'] ?? null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Auth\AuthenticationException;
use Illuminate\Support\Facades\Auth;
use Kanvas\Apps\Models\Apps;
use Kanvas\Companies\Branches\Actions\CreateCompanyBranchActions;
use Kanvas\Companies\Branches\Actions\DeleteCompanyBranchActions;
use Kanvas\Companies\Branches\Actions\UpdateCompanyBranchActions;
Expand All @@ -14,10 +15,13 @@
use Kanvas\Companies\Models\CompaniesBranches;
use Kanvas\Companies\Repositories\CompaniesRepository;
use Kanvas\Enums\StateEnums;
use Kanvas\Filesystem\Traits\HasMutationUploadFiles;
use Kanvas\Users\Models\Users;

class CompanyBranchManagementMutation
{
use HasMutationUploadFiles;

/**
* createCompaniesBranch
*
Expand All @@ -27,7 +31,7 @@ public function createCompaniesBranch(mixed $root, array $request): CompaniesBra
{
$request['input']['users_id'] = Auth::user()->getKey();
$dto = CompaniesBranchPostData::fromArray($request['input']);
$action = new CreateCompanyBranchActions(Auth::user(), $dto);
$action = new CreateCompanyBranchActions(Auth::user(), $dto);

return $action->execute();
}
Expand All @@ -40,11 +44,29 @@ public function createCompaniesBranch(mixed $root, array $request): CompaniesBra
public function updateCompanyBranch(mixed $root, array $request): CompaniesBranches
{
$dto = CompaniesBranchPutData::fromArray($request['input']);
$action = new UpdateCompanyBranchActions(Auth::user(), $dto);
$action = new UpdateCompanyBranchActions(Auth::user(), $dto);

return $action->execute((int) $request['id']);
}

public function attachFileToCompany(mixed $root, array $request): CompaniesBranches
{
$app = app(Apps::class);
$user = auth()->user();
$companyBranch = CompaniesBranches::getById((int) $request['id']);

$company = $companyBranch->company()->first();

CompaniesRepository::userAssociatedToCompanyAndBranch($company, $companyBranch, $user);

return $this->uploadFileToEntity(
model: $companyBranch,
app: $app,
user: $user,
request: $request
);
}

/**
* deleteCompanyBranch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,43 @@

namespace App\GraphQL\Ecosystem\Mutations\Companies;

use Baka\Users\Contracts\UserInterface;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Kanvas\Apps\Models\Apps;
use Kanvas\Companies\Actions\CreateCompaniesAction;
use Kanvas\Companies\Actions\UpdateCompaniesAction;
use Kanvas\Companies\DataTransferObject\CompaniesPutData;
use Kanvas\Companies\DataTransferObject\Company;
use Kanvas\Companies\Jobs\DeleteCompanyJob;
use Kanvas\Companies\Models\Companies;
use Kanvas\Companies\Models\CompaniesBranches;
use Kanvas\Companies\Repositories\CompaniesRepository;
use Kanvas\Enums\StateEnums;
use Kanvas\Filesystem\Actions\AttachFilesystemAction;
use Kanvas\Filesystem\Services\FilesystemServices;
use Kanvas\Filesystem\Traits\HasMutationUploadFiles;
use Kanvas\Users\Actions\AssignRoleAction;
use Kanvas\Users\Models\Users;
use Kanvas\Users\Models\UsersAssociatedApps;
use Kanvas\Users\Models\UsersAssociatedCompanies;
use Kanvas\Users\Repositories\UsersRepository;
use Kanvas\Filesystem\Actions\AttachFilesystemAction;
use Kanvas\Filesystem\Services\FilesystemServices;
use Nuwave\Lighthouse\Exceptions\AuthorizationException;

class CompanyManagementMutation
{
use HasMutationUploadFiles;

/**
* createCompany
*/
public function createCompany(mixed $root, array $request): Companies
{
if (! auth()->user()->isAdmin()) {
throw new AuthorizationException('Only admin can create companies, please contact your admin');
}

if (auth()->user()->isAdmin() && key_exists('users_id', $request['input'])) {
$user = Users::getById($request['input']['users_id']);
UsersRepository::belongsToThisApp($user, app(Apps::class)) ;
Expand All @@ -45,27 +53,59 @@ public function createCompany(mixed $root, array $request): Companies
return $action->execute();
}

/**
* @todo move to service ?
*/
protected function hasCompanyPermission(Companies $company, UserInterface $user): void
{
if (! $user->isAdmin() && $company->users_id != $user->getId()) {
throw new AuthorizationException('Your are not allowed to perform this action for company ' . $company->name);
}
}

/**
* updateCompany
*/
public function updateCompany(mixed $root, array $request): Companies
{
$company = Companies::getById((int) $request['id']);

$this->hasCompanyPermission($company, auth()->user());

if (auth()->user()->isAdmin() && key_exists('users_id', $request['input'])) {
$user = Users::getById($request['input']['users_id']);
UsersRepository::belongsToThisApp($user, app(Apps::class)) ;
UsersRepository::belongsToThisApp($user, app(Apps::class), $company) ;
} else {
$user = auth()->user();
}

$dto = Company::viaRequest($request['input'], $user);
$action = new UpdateCompaniesAction($user, $dto);
$action = new UpdateCompaniesAction($company, $user, $dto);

return $action->execute((int) $request['id']);
return $action->execute();
}

public function attachFileToCompany(mixed $root, array $request): Companies
{
$app = app(Apps::class);
$company = Companies::getById((int) $request['id']);

$this->hasCompanyPermission($company, auth()->user());

return $this->uploadFileToEntity(
model: $company,
app: $app,
user: auth()->user(),
request: $request
);
}

public function updatePhotoProfile(mixed $root, array $request): Companies
{
$company = Companies::getById($request['id']);

$this->hasCompanyPermission($company, auth()->user());

if (! auth()->user()->isAdmin()) {
$company = Companies::getById($request['id']);
CompaniesRepository::userAssociatedToCompany(
Expand Down Expand Up @@ -98,6 +138,11 @@ public function deleteCompany(mixed $root, array $request): bool
if (Users::where('default_company', $request['id'])->count()) {
throw new Exception('You can not delete a company that has users associated');
}

if (! auth()->user()->isAdmin()) {
throw new AuthorizationException('Only admin can delete companies, please contact your admin');
}

DeleteCompanyJob::dispatch((int) $request['id'], Auth::user(), app(Apps::class));

return true;
Expand All @@ -114,6 +159,8 @@ public function addUserToCompany($rootValue, array $request): bool
auth()->user()
);

$this->hasCompanyPermission($company, auth()->user());

$branch = app(CompaniesBranches::class);

$companyDefaultBranch = $company->defaultBranch()->first();
Expand Down Expand Up @@ -173,6 +220,8 @@ public function removeUserFromCompany($rootValue, array $request): bool
auth()->user()
);

$this->hasCompanyPermission($company, auth()->user());

$branch = app(CompaniesBranches::class);

$companyDefaultBranch = $company->defaultBranch()->first();
Expand Down
5 changes: 1 addition & 4 deletions app/GraphQL/Ecosystem/Mutations/Config/ConfigManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ public function setAppSetting(mixed $root, array $request): bool
public function deleteAppSetting(mixed $root, array $request): bool
{
$app = app(Apps::class);
$app->set($request['input']['key'], $request['input']['value']);
$app->delete($request['input']['key']);

return true;
return $app->del($request['key']);
}

public function setCompanySetting(mixed $root, array $request): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Kanvas\Filesystem\Services\FilesystemServices;
use Kanvas\SystemModules\DataTransferObject\SystemModuleEntityInput;
use Kanvas\SystemModules\Repositories\SystemModulesRepository;
use League\Csv\Reader;

class FilesystemManagementMutation
{
Expand Down Expand Up @@ -99,6 +100,25 @@ public function singleFile(mixed $rootValue, array $request): Filesystem
return $filesystem->upload($file, auth()->user());
}

public function uploadCsv(mixed $rootValue, array $request): array
{
$file = $request['file'];
$path = $file->store('csv/' . $file->getClientOriginalName() . uniqid(), 'local');
$path = storage_path('app/' . $path);
$csv = Reader::createFromPath($path, 'r');

$csv->setHeaderOffset(0);
$header = $csv->getHeader();

$fileSystems = $this->singleFile($rootValue, $request);

return [
'filesystem_id' => $fileSystems->id,
'row' => $csv->nth(0),
'header' => $header,
];
}

/**
* Multiple Upload a file, store it on the server and return the path.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

declare(strict_types=1);

namespace App\GraphQL\Ecosystem\Mutations\Filesystem;

use Kanvas\Apps\Models\Apps;
use Kanvas\Filesystem\Actions\CreateFileSystemImportAction;
use Kanvas\Filesystem\Actions\CreateFilesystemMapperAction;
use Kanvas\Filesystem\DataTransferObject\FilesystemImport;
use Kanvas\Filesystem\DataTransferObject\FilesystemMapper;
use Kanvas\Filesystem\Models\Filesystem;
use Kanvas\Filesystem\Models\FilesystemImports;
use Kanvas\Filesystem\Models\FilesystemMapper as ModelsFilesystemMapper;
use Kanvas\Inventory\Regions\Models\Regions;
use Kanvas\SystemModules\Models\SystemModules;

class FilesystemMapperMutation
{
public function create(mixed $root, array $req): ModelsFilesystemMapper
{
$req = $req['input'];
$app = app(Apps::class);
$user = auth()->user();
$branch = $user->getCurrentBranch();
$systemModule = SystemModules::getById($req['system_module_id'], $app);

$mapperDto = FilesystemMapper::viaRequest(
$app,
$branch,
$user,
$systemModule,
$req
);

return (new CreateFilesystemMapperAction($mapperDto))->execute();
}

public function process(mixed $root, array $req): FilesystemImports
{
$input = $req['input'];
$user = auth()->user();
$company = $user->getCurrentCompany();
$app = app(Apps::class);

$filesystem = Filesystem::getByIdFromCompanyApp($input['filesystem_id'], $company, $app);
$mapper = ModelsFilesystemMapper::getByIdFromCompanyApp($input['filesystem_mapper_id'], $company, $app);
$regions = Regions::getByIdFromCompanyApp($input['regions_id'], $company, $app);

$dto = FilesystemImport::from([
'app' => $app,
'users' => $user,
'companies' => $company,
'regions' => $regions,
'companiesBranches' => $user->getCurrentBranch(),
'filesystem' => $filesystem,
'filesystemMapper' => $mapper,
]);

$import = (new CreateFilesystemImportAction($dto))->execute();

return $import;
}
}
7 changes: 5 additions & 2 deletions app/GraphQL/Ecosystem/Mutations/Filesystem/UploadMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\GraphQL\Ecosystem\Mutations\Filesystem;

use Kanvas\Apps\Models\Apps;
use Kanvas\Filesystem\Actions\UploadFileAction;
use Kanvas\Filesystem\Models\Filesystem;

Expand All @@ -16,8 +17,9 @@ public function singleFile(mixed $rootValue, array $request): Filesystem
{
/** @var \Illuminate\Http\UploadedFile $file */
$file = $request['file'];
$app = app(Apps::class);

$uploadFile = new UploadFileAction(auth()->user());
$uploadFile = new UploadFileAction(auth()->user(), $app);

return $uploadFile->execute($file);
}
Expand All @@ -30,9 +32,10 @@ public function multiFile(mixed $rootValue, array $request): array
/** @var \Illuminate\Http\UploadedFile $file */
$files = $request['files'];
$fileSystems = [];
$app = app(Apps::class);

foreach ($files as $file) {
$uploadFile = new UploadFileAction(auth()->user());
$uploadFile = new UploadFileAction(auth()->user(), $app);

$fileSystems[] = $uploadFile->execute($file);
}
Expand Down

This file was deleted.

Loading
Loading