Refactor code for improved readability and consistency
- Removed unnecessary blank lines in various files to enhance code clarity. - Updated comments for consistency and clarity across multiple classes and methods. - Adjusted spacing in test files for better formatting and readability.
This commit is contained in:
@@ -31,7 +31,7 @@ class SyncProductPropertiesJson extends Command
|
||||
// Using cursor to be memory efficient
|
||||
$products = Product::cursor();
|
||||
$count = Product::count();
|
||||
|
||||
|
||||
$bar = $this->output->createProgressBar($count);
|
||||
$bar->start();
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class ProductFilterer
|
||||
if ($this->request->filled('properties')) {
|
||||
foreach ($this->request->input('properties') as $attributeSlug => $values) {
|
||||
$valuesArray = explode(',', $values);
|
||||
|
||||
|
||||
$this->queryBuilder->where(function ($query) use ($attributeSlug, $valuesArray) {
|
||||
foreach ($valuesArray as $value) {
|
||||
$query->orWhereJsonContains("properties_json->{$attributeSlug}", $value);
|
||||
|
||||
@@ -11,7 +11,7 @@ class AppVersionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Check for app updates
|
||||
*
|
||||
*
|
||||
* This api should be triggered when the app is **launched**, and **current version** and **operating system** should be sent in body. It should check if there is any update available for the app.\
|
||||
* **Handle Response**:\
|
||||
* * **Update Required**: If the update is critical/mandatory, show a **blocking modal**. The user cannot dismiss it and must click a button to go to the App Store or Google Play Store.\
|
||||
|
||||
@@ -14,17 +14,17 @@ class AuthRegisterRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
/**
|
||||
* @example 61929248
|
||||
*/
|
||||
'phone_number' => ['required', 'integer', 'between:61000000,71999999', 'unique:users,phone_number'],
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @example Nurmuhammet Allanov
|
||||
*/
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
/**
|
||||
* @example 75 3rd Ave, New York, NY 10003, USA
|
||||
*/
|
||||
'address' => ['required', 'string', 'max:255'],
|
||||
|
||||
@@ -15,7 +15,7 @@ class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* Guest token (walk-in-user)
|
||||
*
|
||||
*
|
||||
* Use when user visits website/app for the first time, and save the token in cache.
|
||||
*/
|
||||
public function guestToken(): JsonResponse
|
||||
@@ -28,8 +28,8 @@ class AuthController extends Controller
|
||||
|
||||
/**
|
||||
* Register user
|
||||
*
|
||||
* Register a new user and send a verification code to their phone number. Then make another request to verification route.
|
||||
*
|
||||
* Register a new user and send a verification code to their phone number. Then make another request to verification route.
|
||||
*/
|
||||
public function register(AuthRegisterRequest $request): JsonResponse
|
||||
{
|
||||
@@ -46,7 +46,7 @@ class AuthController extends Controller
|
||||
|
||||
/**
|
||||
* Login
|
||||
*
|
||||
*
|
||||
* Send a verification code to the phone number. Then make another request to verify route.
|
||||
*/
|
||||
public function login(AuthLoginRequest $request): JsonResponse
|
||||
@@ -62,7 +62,7 @@ class AuthController extends Controller
|
||||
|
||||
/**
|
||||
* Verify the code
|
||||
*
|
||||
*
|
||||
* After verification, bearer token will be returned.
|
||||
*/
|
||||
public function verify(AuthVerifyRequest $request): JsonResponse
|
||||
|
||||
@@ -38,7 +38,7 @@ class OrderController extends Controller
|
||||
*/
|
||||
public function store(CheckoutOrderRequest $request, CreateOrderService $service): JsonResponse
|
||||
{
|
||||
$order = $service->execute(auth()->user(), $request->validated());
|
||||
$order = $service->execute(auth()->user(), $request->all());
|
||||
|
||||
$url = null;
|
||||
if ($request->payment_type_id == 3) {
|
||||
@@ -81,7 +81,6 @@ class OrderController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Order $order
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Order $order)
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Api\V1\Product\Resources;
|
||||
|
||||
use App\Http\Resources\MediaResource;
|
||||
use App\Repositories\Ecommerce\Product\Property\PropertyRepository;
|
||||
use App\Http\Controllers\Api\V1\Product\Resources\Variant\ProductVariantResource;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductIndexResource extends JsonResource
|
||||
|
||||
@@ -10,7 +10,7 @@ class CheckForUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Requests\Api\V1\Auth;
|
||||
|
||||
use App\Rules\VerificationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ class AuthVerifyRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
/**
|
||||
* @example 61929248
|
||||
*/
|
||||
'phone_number' => ['required', 'integer', 'between:61000000,65999999'],
|
||||
|
||||
/**
|
||||
/**
|
||||
* @example 99934
|
||||
*/
|
||||
'code' => ['required', 'integer', new VerificationRule($this->phone_number)],
|
||||
|
||||
@@ -23,7 +23,7 @@ trait HasPropertiesJson
|
||||
|
||||
foreach ($this->properties as $property) {
|
||||
$attributeSlug = $property->attribute->slug;
|
||||
|
||||
|
||||
if (! isset($propertiesJson[$attributeSlug])) {
|
||||
$propertiesJson[$attributeSlug] = [];
|
||||
}
|
||||
@@ -34,12 +34,12 @@ trait HasPropertiesJson
|
||||
if ($value->value) {
|
||||
$propertiesJson[$attributeSlug][] = $value->value->key;
|
||||
}
|
||||
|
||||
|
||||
if ($value->product_custom_value) {
|
||||
$propertiesJson[$attributeSlug][] = $value->product_custom_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Unique values just in case
|
||||
$propertiesJson[$attributeSlug] = array_values(array_unique($propertiesJson[$attributeSlug]));
|
||||
}
|
||||
|
||||
@@ -27,16 +27,16 @@ class Product extends Model implements HasMedia, Viewable
|
||||
*/
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Has Schemaless Attributes (spatie/laravel-schemaless-attributes)
|
||||
*/
|
||||
use HasSchemalessAttributes;
|
||||
|
||||
/**
|
||||
* Has Properties Json
|
||||
*/
|
||||
use HasPropertiesJson;
|
||||
|
||||
/**
|
||||
* Has Schemaless Attributes (spatie/laravel-schemaless-attributes)
|
||||
*/
|
||||
use HasSchemalessAttributes;
|
||||
|
||||
/**
|
||||
* Has Slug (spatie/laravel-sluggable)
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property int $id
|
||||
* @property string $version
|
||||
* @property string $os
|
||||
* @property bool $important
|
||||
* @property bool $important
|
||||
* @property string $notes
|
||||
* @property \Carbon\Carbon|null $created_at
|
||||
* @property \Carbon\Carbon|null $updated_at
|
||||
|
||||
@@ -38,7 +38,6 @@ class Warning extends Resource
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
@@ -68,7 +67,6 @@ class Warning extends Resource
|
||||
/**
|
||||
* Get the cards available for the request.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function cards(NovaRequest $request)
|
||||
@@ -79,7 +77,6 @@ class Warning extends Resource
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function filters(NovaRequest $request)
|
||||
@@ -90,7 +87,6 @@ class Warning extends Resource
|
||||
/**
|
||||
* Get the lenses available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function lenses(NovaRequest $request)
|
||||
@@ -101,7 +97,6 @@ class Warning extends Resource
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function actions(NovaRequest $request)
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Dedoc\Scramble\Scramble;
|
||||
use Dedoc\Scramble\Support\Generator\OpenApi;
|
||||
use Dedoc\Scramble\Support\Generator\SecurityRequirement;
|
||||
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class DocumentationServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -24,14 +24,14 @@ class DocumentationServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
Scramble::configure()
|
||||
->withDocumentTransformers(function (OpenApi $openApi) {
|
||||
$openApi->components->securitySchemes['api-token'] = SecurityScheme::apiKey('header', 'Api-token');
|
||||
$openApi->components->securitySchemes['bearer'] = SecurityScheme::http('bearer');
|
||||
->withDocumentTransformers(function (OpenApi $openApi) {
|
||||
$openApi->components->securitySchemes['api-token'] = SecurityScheme::apiKey('header', 'Api-token');
|
||||
$openApi->components->securitySchemes['bearer'] = SecurityScheme::http('bearer');
|
||||
|
||||
$openApi->security[] = new SecurityRequirement([
|
||||
'api-token' => [],
|
||||
'bearer' => [],
|
||||
]);
|
||||
});
|
||||
$openApi->security[] = new SecurityRequirement([
|
||||
'api-token' => [],
|
||||
'bearer' => [],
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ class ProductRepository
|
||||
|
||||
/**
|
||||
* Update query builder with resource relationship
|
||||
*
|
||||
* @param mixed $resource
|
||||
*
|
||||
* @param mixed $resource
|
||||
*/
|
||||
public function queryAsFromResource($resource): self
|
||||
{
|
||||
@@ -277,8 +277,8 @@ class ProductRepository
|
||||
|
||||
/**
|
||||
* Ajax paginate
|
||||
*
|
||||
* @param mixed $products
|
||||
*
|
||||
* @param mixed $products
|
||||
*/
|
||||
public static function ajaxPaginate($products): JsonResponse
|
||||
{
|
||||
|
||||
@@ -13,15 +13,12 @@ class CreateOrderService
|
||||
{
|
||||
/**
|
||||
* Create a new order for the user
|
||||
*
|
||||
* @param User $user
|
||||
* @param array $data
|
||||
* @return Order
|
||||
*/
|
||||
public function execute(User $user, array $data): Order
|
||||
{
|
||||
return DB::transaction(function () use ($user, $data) {
|
||||
// 1. Create the order
|
||||
info(['service' => $data]);
|
||||
$order = Order::create($data);
|
||||
|
||||
// 2. Process Cart Items
|
||||
|
||||
Reference in New Issue
Block a user