Skip to content

Commit

Permalink
Merge pull request #891 from bakaphp/development
Browse files Browse the repository at this point in the history
v1.0-BETA21
  • Loading branch information
kaioken authored Feb 7, 2024
2 parents 66739c5 + 8c32e33 commit f516f22
Show file tree
Hide file tree
Showing 38 changed files with 1,084 additions and 660 deletions.
13 changes: 12 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,15 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "daily"
labels:
- "dependencies"

# Maintain dependencies for Composer
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
labels:
- "php"
- "dependencies"
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public function addUserToBranch($rootValue, array $request): bool
$branch
);

$branch->set('total_users', $branch->users()->count());

return true;
}

Expand Down
13 changes: 9 additions & 4 deletions app/GraphQL/Ecosystem/Mutations/Config/ConfigManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class ConfigManagement
public function setAppSetting(mixed $root, array $request): bool
{
$app = app(Apps::class);
$app->set($request['input']['key'], $request['input']['value']);
$user = auth()->user();
$isPublic = $user->isAdmin() && isset($request['input']['public']) ? (bool) $request['input']['public'] : false;
$app->set($request['input']['key'], $request['input']['value'], $isPublic);

return true;
}
Expand All @@ -32,7 +34,9 @@ public function deleteAppSetting(mixed $root, array $request): bool
public function setCompanySetting(mixed $root, array $request): bool
{
$companies = CompaniesRepository::getByUuid($request['input']['entity_uuid'], app(Apps::class));
$companies->set($request['input']['key'], $request['input']['value']);
$user = auth()->user();
$isPublic = $user->isAdmin() && isset($request['input']['public']) ? (bool) $request['input']['public'] : false;
$companies->set($request['input']['key'], $request['input']['value'], $isPublic);

return true;
}
Expand All @@ -50,8 +54,9 @@ public function setUserSetting(mixed $root, array $request): bool
$user = Users::getByUuid($request['input']['entity_uuid']);

UsersRepository::belongsToThisApp($user, app(Apps::class));

$user->set($request['input']['key'], $request['input']['value']);
$currentUser = auth()->user();
$isPublic = $currentUser->isAdmin() && isset($request['input']['public']) ? (bool) $request['input']['public'] : false;
$user->set($request['input']['key'], $request['input']['value'], $isPublic);

return true;
}
Expand Down
17 changes: 12 additions & 5 deletions app/GraphQL/Ecosystem/Queries/Config/ConfigManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\GraphQL\Ecosystem\Queries\Config;

use Baka\Users\Contracts\UserInterface;
use Kanvas\Apps\Models\Apps;
use Kanvas\Companies\Repositories\CompaniesRepository;
use Kanvas\Users\Models\Users;
Expand All @@ -13,29 +14,35 @@ class ConfigManagement
{
public function getAppSetting(mixed $root, array $request): array
{
return $this->parseSettings(app(Apps::class)->getAll());
$user = auth()->user();

return $this->parseSettings(app(Apps::class)->getAll(), $user);
}

public function getCompanySetting(mixed $root, array $request): array
{
return $this->parseSettings(CompaniesRepository::getByUuid($request['entity_uuid'], app(Apps::class))->getAll());
$user = auth()->user();

return $this->parseSettings(CompaniesRepository::getByUuid($request['entity_uuid'], app(Apps::class))->getAll(), $user);
}

public function getUserSetting(mixed $root, array $request): array
{
$user = Users::getByUuid($request['entity_uuid']);
$currentUser = auth()->user();
UsersRepository::belongsToThisApp($user, app(Apps::class));

return $this->parseSettings($user->getAll());
return $this->parseSettings($user->getAll(), $currentUser);
}

public function parseSettings(array $data): array
public function parseSettings(array $data, UserInterface $user): array
{
$settings = [];
foreach ($data as $key => $value) {
$settings[] = [
'key' => $key,
'value' => gettype($value) != 'array' ? (string)$value : $value,
'value' => gettype($value['value']) != 'array' ? (string)$value['value'] : $value['value'],
'public' => $user->isAdmin() ? (bool) $value['public'] : false,
];
}

Expand Down
62 changes: 62 additions & 0 deletions app/GraphQL/Guild/Mutations/Leads/LeadSourceManagementMutation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace App\GraphQL\Guild\Mutations\Leads;

use Kanvas\Apps\Models\Apps;
use Kanvas\Companies\Repositories\CompaniesRepository;
use Kanvas\Guild\Leads\Models\LeadType;
use Kanvas\Guild\LeadSources\Actions\CreateLeadSourceAction;
use Kanvas\Guild\LeadSources\DataTransferObject\LeadSource;
use Kanvas\Guild\LeadSources\Models\LeadSource as LeadSourceModel;

class LeadSourceManagementMutation
{
public function create(mixed $root, array $request): LeadSourceModel
{
$data = $this->validate($request['input']);

$leadSource = LeadSource::from($data);

return (new CreateLeadSourceAction($leadSource))->execute();
}

public function update(mixed $root, array $request): LeadSourceModel
{
$input = $this->validate($request['input']);

$leadSource = LeadSourceModel::getByUuidFromCompanyApp(
$request['id'],
company:CompaniesRepository::getByUuid($input['companies_id']),
app: app(Apps::class)
);
$leadSource->update([
'name' => $input['name'],
'description' => $input['description'],
'is_active' => $input['is_active'],
'leads_types_id' => $input['leads_types_id'],
]);

return $leadSource;
}

public function delete(mixed $root, array $request): bool
{
$leadSource = LeadSourceModel::getByUuidFromCompanyApp($request['id'], app: app(Apps::class));
CompaniesRepository::userAssociatedToCompany($leadSource->company, auth()->user());

return $leadSource->delete();
}

public function validate(array $input): array
{
$input['app'] = app(Apps::class);
$input['company'] = CompaniesRepository::getByUuid($input['companies_id'], app: app(Apps::class), user: auth()->user());
CompaniesRepository::userAssociatedToCompany($input['company'], auth()->user());
$leadType = LeadType::getByUuidFromCompanyApp($input['leads_types_id'], company:$input['company'], app: app(Apps::class));
$input['leads_types_id'] = $leadType->getId();

return $input;
}
}
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@
"laravel/scout": "^10.2",
"laravel/socialite": "^5.6",
"laravel/tinker": "^2.7",
"lcobucci/jwt": "^4.3",
"lcobucci/jwt": "^5.2",
"league/flysystem-aws-s3-v3": "^3.12",
"meilisearch/meilisearch-php": "^1.4",
"mll-lab/graphql-php-scalars": "^6.0",
"mll-lab/laravel-graphiql": "^3.1.0",
"nuwave/lighthouse": "^6.0",
"phpclassic/php-shopify": "^1.2",
"powersync/authorizenet-sdk-php": "^2.0",
"sentry/sentry-laravel": "^3.2",
"shopify/shopify-api": "^4.1",
"sentry/sentry-laravel": "^4.2",
"shopify/shopify-api": "^5.3",
"silber/bouncer": "^1.0",
"spatie/data-transfer-object": "^3.7",
"spatie/laravel-data": "^3.1",
"spatie/laravel-google-cloud-storage": "^2.2",
"spatie/laravel-health": "^1.22",
"spatie/laravel-queueable-action": "^2.14",
"spatie/laravel-webhook-server": "^3.4",
"symfony/expression-language": "^6.3",
"symfony/http-client": "^6.2",
"symfony/mailgun-mailer": "^6.2",
"symfony/expression-language": "^7.0",
"symfony/http-client": "^7.0",
"symfony/mailgun-mailer": "^7.0",
"timokoerber/laravel-one-time-operations": "^1.4",
"vladimir-yuldashev/laravel-queue-rabbitmq": "^13.3",
"vlucas/phpdotenv": "^5.5",
Expand Down
Loading

0 comments on commit f516f22

Please sign in to comment.