Skip to content

Commit

Permalink
Merge pull request #299 from mayank-webkul/create-order
Browse files Browse the repository at this point in the history
Issues Fixing
  • Loading branch information
vivek-webkul committed Sep 24, 2024
2 parents b0dd177 + f145220 commit 3cc2eff
Show file tree
Hide file tree
Showing 60 changed files with 395 additions and 319 deletions.
74 changes: 37 additions & 37 deletions Postman_APIs/Collections/GraphQL-API.postman_collection.json

Large diffs are not rendered by default.

22 changes: 2 additions & 20 deletions src/DataGrids/PushNotificationDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Webkul\Core\Models\Channel;
use Webkul\Core\Models\Locale;
use Webkul\DataGrid\DataGrid;

class PushNotificationDataGrid extends DataGrid
Expand All @@ -24,14 +22,6 @@ class PushNotificationDataGrid extends DataGrid
*/
public function prepareQueryBuilder()
{
$whereInLocales = (core()->getRequestedLocaleCode() === 'all')
? Locale::query()->pluck('code')->toArray()
: [core()->getRequestedLocaleCode()];

$whereInChannels = (core()->getRequestedChannelCode() === 'all')
? Channel::query()->pluck('code')->toArray()
: [core()->getRequestedChannelCode()];

$queryBuilder = DB::table('push_notifications as pn')
->select(
'pn.id as notification_id',
Expand All @@ -46,16 +36,8 @@ public function prepareQueryBuilder()
'pn_trans.channel',
'pn_trans.locale',
)
->leftJoin('push_notification_translations as pn_trans', function ($leftJoin) use ($whereInLocales, $whereInChannels) {
$leftJoin->on('pn.id', '=', 'pn_trans.push_notification_id')
->whereIn('pn_trans.locale', $whereInLocales)
->whereIn('pn_trans.channel', $whereInChannels);
})
->groupBy(
'pn_trans.push_notification_id',
'pn_trans.channel',
'pn_trans.locale'
);
->leftJoin('push_notification_translations as pn_trans', 'pn.id', '=', 'pn_trans.push_notification_id')
->groupBy('pn.id');

$this->addFilter('notification_id', 'pn.id');

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Admin/NotificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function edit(int $id)
*/
public function update(NotificationRequest $request, int $id)
{
Event::dispatch('settings.notification.update.befor', $id);
Event::dispatch('settings.notification.update.before', $id);

$notification = $this->notificationRepository->update($request->validated(), $id);

Expand Down Expand Up @@ -162,7 +162,7 @@ public function massUpdate(MassUpdateRequest $request): JsonResponse
}

return new JsonResponse([
'message' => trans('bagisto_graphql::app.admin.settings.notification.index.mass-update-success'),
'message' => trans('bagisto_graphql::app.admin.settings.notification.mass-update-success'),
], 200);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Http/Requests/NotificationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ public function rules()
'image' => 'array',
'image.*' => 'mimes:jpeg,jpg,bmp,png',
'type' => 'required',
'channel' => 'nullable',
'channels' => 'required|array',
'channels.*' => 'required',
'product_category_id' => 'nullable|integer',
'locale' => 'string',
'status' => 'boolean',
];
}
}
6 changes: 6 additions & 0 deletions src/Mutations/Admin/CMS/CmsPageMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public function update(mixed $rootValue, array $args, GraphQLContext $context)

$id = $args['id'];

$page = $this->pageRepository->find($id);

if (! $page) {
throw new CustomException(trans('bagisto_graphql::app.admin.cms.not-found'));
}

unset($data[$locale]['channels'], $data[$locale]['locale']);

bagisto_graphql()->validate($data, [
Expand Down
7 changes: 4 additions & 3 deletions src/Mutations/Admin/Catalog/Categories/CategoryMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ public function update(mixed $rootValue, array $args, GraphQLContext $context)
$fail(trans('bagisto_graphql::app.admin.catalog.categories.already-taken'));
}
}],
$locale.'.name' => 'required',
'image.*' => 'mimes:jpeg,jpg,bmp,png',
'parent_id' => 'required|exists:categories,id',
$locale.'.name' => 'required',
$locale.'.description' => 'required_if:display_mode,==,description_only,products_and_description',
'image.*' => 'mimes:jpeg,jpg,bmp,png',
'parent_id' => 'required|exists:categories,id',
]);

try {
Expand Down
8 changes: 8 additions & 0 deletions src/Mutations/Admin/Catalog/Products/ProductMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Validator;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
use Webkul\Admin\Validations\ProductCategoryUniqueSlug;
use Webkul\Core\Rules\Decimal;
use Webkul\Core\Rules\Slug;
use Webkul\GraphQLAPI\Validators\CustomException;
Expand Down Expand Up @@ -64,6 +65,12 @@ public function store(mixed $rootValue, array $args, GraphQLContext $context)

$args['super_attributes'] = $superAttributes;

bagisto_graphql()->validate($args, [
'super_attributes' => 'required|array',
'super_attributes.*' => 'required|array',
'super_attributes.*.*' => 'required|exists:attribute_options,id',
]);

try {
Event::dispatch('catalog.product.create.before');

Expand Down Expand Up @@ -267,6 +274,7 @@ public function validateFormData(int $id, array $data)

$validateRules = array_merge($product->getTypeInstance()->getTypeValidationRules(), [
'sku' => ['required', 'unique:products,sku,'.$id, new Slug],
'url_key' => ['required', new ProductCategoryUniqueSlug('products', $id)],
'special_price_from' => 'nullable|date',
'special_price_to' => 'nullable|date|after_or_equal:special_price_from',
'special_price' => ['nullable', new Decimal, 'lt:price'],
Expand Down
8 changes: 6 additions & 2 deletions src/Mutations/Admin/Setting/InventorySourceMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public function store(mixed $rootValue, array $args, GraphQLContext $context)
'contact_email' => 'required|email',
'contact_number' => 'required',
'street' => 'required',
'country' => 'required',
'country' => 'required|exists:countries,code',
'state' => 'required',
'city' => 'required',
'postcode' => 'required',
'latitude' => 'nullable|numeric|between:-90,90',
'longitude' => 'nullable|numeric|between:-180,180',
]);

try {
Expand Down Expand Up @@ -75,10 +77,12 @@ public function update(mixed $rootValue, array $args, GraphQLContext $context)
'contact_email' => 'required|email',
'contact_number' => 'required',
'street' => 'required',
'country' => 'required',
'country' => 'required|exists:countries,code',
'state' => 'required',
'city' => 'required',
'postcode' => 'required',
'latitude' => 'nullable|numeric|between:-90,90',
'longitude' => 'nullable|numeric|between:-180,180',
]);

$inventorySource = $this->inventorySourceRepository->find($args['id']);
Expand Down
1 change: 1 addition & 0 deletions src/Mutations/Admin/Setting/RoleMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function update(mixed $rootValue, array $args, GraphQLContext $context)
bagisto_graphql()->validate($args, [
'name' => 'required',
'permission_type' => 'required',
'description' => 'required',
]);

$role = $this->roleRepository->find($args['id']);
Expand Down
28 changes: 13 additions & 15 deletions src/Mutations/Admin/Setting/UserMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,12 @@ public function login(mixed $rootValue, array $args, GraphQLContext $context)
public function store(mixed $rootValue, array $args, GraphQLContext $context)
{
bagisto_graphql()->validate($args, [
'name' => 'required',
'email' => 'required|email|unique:admins,email',
'password' => 'nullable|min:6',
'password_confirmation' => 'nullable|required_with:password|same:password',
'role_id' => 'required',
'status' => 'sometimes',
'image' => 'sometimes',
'name' => 'required',
'email' => 'required|email|unique:admins,email',
'password' => 'nullable|min:6|confirmed',
'role_id' => 'required',
'status' => 'sometimes',
'image' => 'sometimes',
]);

if (! $this->roleRepository->find($args['role_id'])) {
Expand Down Expand Up @@ -133,13 +132,12 @@ public function store(mixed $rootValue, array $args, GraphQLContext $context)
public function update(mixed $rootValue, array $args, GraphQLContext $context)
{
bagisto_graphql()->validate($args, [
'name' => 'required',
'email' => 'required|email|unique:admins,email,'.$args['id'],
'password' => 'nullable',
'password_confirmation' => 'nullable|required_with:password|same:password',
'status' => 'sometimes',
'role_id' => 'required',
'image' => 'sometimes',
'name' => 'required',
'email' => 'required|email|unique:admins,email,'.$args['id'],
'password' => 'nullable|min:6|confirmed',
'status' => 'sometimes',
'role_id' => 'required',
'image' => 'sometimes',
]);

$admin = $this->adminRepository->find($args['id']);
Expand Down Expand Up @@ -173,7 +171,7 @@ public function update(mixed $rootValue, array $args, GraphQLContext $context)

bagisto_graphql()->uploadImage($admin, $imageUrl, 'admins/', 'image');

if ($isPasswordChanged) {
if ($isPasswordChanged ?? false) {
Event::dispatch('user.admin.update-password', $admin);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Mutations/Shop/Customer/AddressesMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ public function store(mixed $rootValue, array $args, GraphQLContext $context)
'first_name' => ['required'],
'last_name' => ['required'],
'address' => ['required', 'array', 'min:1'],
'address.*' => ['required', 'string'],
'country' => core()->isCountryRequired() ? ['required'] : ['nullable'],
'state' => core()->isStateRequired() ? ['required'] : ['nullable'],
'city' => ['required', 'string'],
'postcode' => core()->isPostCodeRequired() ? ['required', 'numeric'] : ['numeric'],
'phone' => ['required', new PhoneNumber],
'vat_id' => [new VatIdRule()],
'email' => ['required'],
'email' => ['required', 'email'],
]);

try {
Expand Down
6 changes: 3 additions & 3 deletions src/Mutations/Shop/Customer/CartMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Webkul\GraphQLAPI\Mutations\Shop\Customer;

use Webkul\Checkout\Facades\Cart;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
use Webkul\Checkout\Facades\Cart;
use Webkul\Checkout\Repositories\CartItemRepository;
use Webkul\Checkout\Repositories\CartRepository;
use Webkul\GraphQLAPI\Validators\CustomException;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Checkout\Repositories\CartItemRepository;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;

class CartMutation extends Controller
{
Expand Down
9 changes: 4 additions & 5 deletions src/Mutations/Shop/Customer/RegistrationMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public function __construct(
public function signUp(mixed $rootValue, array $args, GraphQLContext $context)
{
bagisto_graphql()->validate($args, [
'email' => 'email|required|unique:customers,email',
'first_name' => 'string|required',
'last_name' => 'string|required',
'password' => 'min:6|required',
'password_confirmation' => 'required|required_with:password|same:password',
'email' => 'email|required|unique:customers,email',
'first_name' => 'string|required',
'last_name' => 'string|required',
'password' => 'min:6|required|confirmed',
]);

$this->create($args);
Expand Down
2 changes: 1 addition & 1 deletion src/Queries/Admin/Cms/FilterCmsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Webkul\GraphQLAPI\Queries\Admin\Cms;

use Illuminate\Support\Arr;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Arr;
use Webkul\GraphQLAPI\Queries\BaseFilter;

class FilterCmsPage extends BaseFilter
Expand Down
Loading

0 comments on commit 3cc2eff

Please sign in to comment.