restore composer.json, add mysqli extension

This commit is contained in:
2026-04-15 17:02:52 +05:00
commit 77cf56a348
4317 changed files with 1397107 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?php
namespace App\Http\Requests\Dashboard\Branch;
use Illuminate\Foundation\Http\FormRequest;
class Request extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get'))
{
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'address' => 'required|array',
'address.*' => 'required|string',
'schedule' => 'required|array',
'schedule.*' => 'required|string',
'map' => 'required|array',
'map.*' => 'required|string',
'phone' => 'required|string',
'orientation' => 'required|array',
];
}
public function getName(): array
{
return (array) $this->get('name');
}
public function getAddress(): array
{
return (array) $this->get('address');
}
public function getSchedule(): array
{
return (array) $this->get('schedule');
}
public function getMap(): array
{
return (array) $this->get('map');
}
public function getPhone(): string
{
return (string) $this->get('phone');
}
public function getOrientation(): array
{
return $this->get('orientation');
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Http\Requests\Dashboard\Brand;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'array',
'name.*' => 'required',
'image' => 'required|mimes:jpeg,png,jpg',
'position' => 'required|integer'
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\Dashboard\Brand;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required',
'image' => 'nullable|mimes:jpeg,jpg,png',
'position' => 'required|integer'
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
}

View File

@@ -0,0 +1,104 @@
<?php
namespace App\Http\Requests\Dashboard\Category;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
class Request extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'image' => 'nullable|mimes:jpg,jpeg,png',
'parent_id' => 'nullable',
'brands' => 'nullable|array',
'position' => 'nullable|numeric'
];
}
public function getName(): array
{
return $this->get('name');
}
public function getSlug(): string
{
return Str::slug($this->get('name')['uz']);
}
public function getImage(): string
{
if ($this->hasFile('image')) {
if (env('FILESYSTEM_DISK') == 's3') {
$folder = "uploads/categories";
return (string) $this->file('image')->store($folder);
} else {
return $this->file('image')->store('uploads/categories', 'local');
}
} else {
return 'null';
}
}
public function getPublished()
{
if ($this->get('published') == 'true') {
return true;
}
return false;
}
public function getFilterPower()
{
if ($this->get('is_filter_power') == 'true') {
return true;
}
return false;
}
public function getCredit()
{
if ($this->get('credit') == 'true') {
return true;
}
return false;
}
public function getParentId()
{
if ($this->get('parent_id') > 0)
return $this->get('parent_id');
return null;
}
public function getPosition(): int
{
return $this->get('position');
}
public function getPopular(): bool
{
if ($this->get('popular') == 'false') {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,113 @@
<?php
namespace App\Http\Requests\Dashboard\Category;
use App\Models\Category;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
class Update extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'image' => 'nullable',
'parent_id' => 'nullable',
'popular' => 'nullable',
'brands' => 'nullable|array',
'position' => 'nullable|numeric'
];
}
public function getName(): array
{
return $this->get('name');
}
public function getSlug(): string
{
return Str::slug($this->get('name')['uz']);
}
public function getImage(Category $category): string
{
if ($this->hasFile('image')) {
if (env('FILESYSTEM_DISK') == 's3') {
// delete old image from s3
Storage::disk('s3')->delete($category->image);
$folder = "uploads/categories";
return (string) $this->file('image')->store($folder);
} else {
// detele old image
if (is_file($category->image)) {
unlink($category->image);
}
return $this->file('image')->store('uploads/categories', 'local');
}
} else {
return 'null';
}
}
public function getFilterPower()
{
if ($this->get('is_filter_power') == 'true') {
return true;
}
return false;
}
public function getPublished()
{
if ($this->get('published') == 'true') {
return true;
}
return false;
}
public function getCredit()
{
if ($this->get('credit') == 'true') {
return true;
}
return false;
}
public function getParentId()
{
if ($this->get('parent_id') > 0)
return $this->get('parent_id');
return null;
}
public function getPosition(): int
{
return $this->get('position');
}
public function getPopular(): bool
{
if ($this->get('popular') == 'false') {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Http\Requests\Dashboard\City;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'region_id' => 'required|numeric|exists:regions,id'
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
public function getRegion(): int
{
return $this->get('region_id');
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Http\Requests\Dashboard\City;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'region_id' => 'required|numeric|exists:regions,id'
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
public function getRegion(): int
{
return $this->get('region_id');
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Http\Requests\Dashboard\Color;
use Illuminate\Foundation\Http\FormRequest;
class Request extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get'))
{
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string'
];
}
public function getName(): array
{
return (array) $this->get('name');
}
public function getColor(): string
{
return (string) $this->get('color');
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Http\Requests\Dashboard\Compilation;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [
//
];
}
return [
'title' => 'array',
'title.*' => 'required',
'published' => 'required',
//'category_id' => 'required'
];
}
/**
* @return array
*/
public function getTitle(): array
{
return $this->get('title');
}
/**
* @return bool
*/
public function getPublished(): bool
{
return $this->get('published');
}
/**
* @return |null
*/
public function getCategory()
{
if ($this->get('category_id')) {
$this->get('category_id');
}
return null;
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests\Dashboard\Compilation;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [
//
];
}
return [
'title' => 'array',
'title.*' => 'required',
'published' => 'required',
//'category_id' => 'required',
];
}
/**
* @return array
*/
public function getTitle(): array
{
return $this->get('title');
}
/**
* @return bool
*/
public function getPublished(): bool
{
return $this->get('published');
}
public function getCategory()
{
if ($this->get('category_id')) {
$this->get('category_id');
}
return null;
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Requests\Dashboard\Currency;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'dollar' => 'required',
'euro' => 'required'
];
}
/**
* @return int
*/
public function getDollar(): int
{
return $this->get('dollar');
}
/**
* @return int
*/
public function getEuro(): int
{
return $this->get('euro');
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Dashboard\File;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'file' => 'required|mimes:jpg,png,jpeg'
];
}
}

View File

@@ -0,0 +1,163 @@
<?php
namespace App\Http\Requests\Dashboard\Order;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [
//
];
}
return [
'product_total' => 'required',
'total' => 'required',
//'orders.price_delivery' => 'required',
//'orders.type_delivery' => 'required',
//'orders.payment_type' => 'required',
//'orders.discount' => 'nullable',
'products' => 'array|required',
//'orders.address.first_name' => 'required',
//'orders.address.phone' => 'required',
];
}
// protected function getValidatorInstance() {
// $validator = parent::getValidatorInstance();
// if ($this->isMethod('post')) {
//
// $validator->sometimes('orders.branch_id', 'required', function($input) {
// return $input->orders['type_delivery'] == 2;
// });
//
// $validator->sometimes('orders.shipment_date', 'required', function($input) {
// return $input->orders['type_delivery'] == 2;
// });
//
// $validator->sometimes('orders.address.city', 'required', function($input) {
// return $input->orders['type_delivery'] == 1;
// });
//
// $validator->sometimes('orders.address.region', 'required', function($input) {
// return $input->orders['type_delivery'] == 1;
// });
//
// $validator->sometimes('orders.address.street', 'required', function($input) {
// return $input->orders['type_delivery'] == 1;
// });
// }
// return $validator;
// }
public function getPhone(): int
{
return $this->get('orders')['address']['phone'];
}
public function getFirstName(): string
{
return $this->get('orders')['address']['first_name'];
}
/**
* @return mixed|null
*/
public function getCity()
{
return $this->get('orders')['address']['city'] ? $this->get('orders')['address']['city'] : null;
}
public function getRegion()
{
return $this->get('orders')['address']['region'] ? $this->get('orders')['address']['region'] : null;
}
public function getStreet()
{
return $this->get('orders')['address']['street'] ? $this->get('orders')['address']['street'] : null;
}
public function getApartment()
{
return $this->get('orders')['address']['apartment'] ? $this->get('orders')['address']['apartment'] : null;
}
public function getFloor()
{
return $this->get('orders')['address']['floor'] ? $this->get('orders')['address']['floor'] : null;
}
public function getEntrance()
{
return $this->get('orders')['address']['entrance'] ? $this->get('orders')['address']['entrance'] : null;
}
public function getProductTotal(): int
{
return (int) $this->get('product_total');
}
public function getTotal(): int
{
return $this->get('total');
}
public function getDeliveryPrice()
{
return $this->get('orders')['price_delivery'];
}
/**
* @return mixed|null
*/
public function shipment_date()
{
return $this->get('orders')['shipment_date'] ? $this->get('orders')['shipment_date'] : null;
}
public function getTypeDelivery(): int
{
return $this->get('orders')['type_delivery'];
}
public function getPaymentType(): string
{
return $this->get('orders')['payment_type'];
}
/**
* @return mixed|null
*/
public function getBranchID()
{
return $this->get('orders')['branch_id'] ? $this->get('orders')['branch_id'] : null;
}
/**
* @return mixed
*/
public function getProducts()
{
return $this->get('products');
}
public function getDiscount()
{
return $this->get('orders')['discount'] ? $this->get('orders')['discount'] : null;
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Http\Requests\Dashboard\Page;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'body' => 'required|array',
'body.*' => 'required|string',
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
/**
* @return array
*/
public function getBody(): array
{
return $this->get('body');
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Http\Requests\Dashboard\Page;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'body' => 'required|array',
'body.*' => 'required|string',
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
/**
* @return array
*/
public function getBody(): array
{
return $this->get('body');
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests\Dashboard\Partner;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name_uz' => 'required|string',
'name_ru' => 'required|string',
'image' => 'required|image',
'status' => 'required|in:published,new,soon',
'video_url' => 'nullable|url',
'description_uz' => 'required|string',
'description_ru' => 'required|string',
'position' => 'required|integer',
'is_price' => 'nullable|boolean',
];
}
/**
* @return array
*/
public function getName(): array
{
return [
'uz' => $this->get('name_uz'),
'ru' => $this->get('name_ru')
];
}
public function getDescription(): array|null
{
return [
'uz' => $this->get('description_uz'),
'ru' => $this->get('description_ru')
];
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests\Dashboard\Partner;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
*
* @return array
*/
public function rules()
{
return [
'name_uz' => 'required|string',
'name_ru' => 'required|string',
'image' => 'nullable|image',
'status' => 'required|in:published,new,soon',
'video_url' => 'nullable|url',
'description_uz' => 'required|string',
'description_ru' => 'required|string',
'position' => 'required|integer',
'with_price' => 'nullable|boolean',
];
}
/**
* @return array
*/
public function getName(): array
{
return [
'uz' => $this->get('name_uz'),
'ru' => $this->get('name_ru')
];
}
public function getDescription(): array|null
{
return [
'uz' => $this->get('description_uz'),
'ru' => $this->get('description_ru')
];
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Http\Requests\Dashboard\Post;
use App\Models\Post;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|string',
'content' => 'required|string',
'image' => 'required|image',
'language' => 'required|string',
'topped' => 'nullable|boolean',
'type' => 'required|string|in:news,article,sales,media',
'position' => 'nullable|integer'
];
}
public function getName():string
{
return (string) $this->get('name');
}
public function getBody():string
{
return (string) $this->get('content');
}
public function getLanguage():string
{
return (string) $this->get('language');
}
public function getTopped(): bool
{
return (bool) $this->get('topped');
}
public function getType(): string
{
return (string) $this->get('type');
}
public function getPosition(): int|null
{
if ($this->position) {
return $this->get('position');
} else {
if (Post::count() === 0) {
return 0;
}
return Post::max('position') + 1;
}
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Http\Requests\Dashboard\Post;
use App\Models\Post;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|string',
'content' => 'required|string',
'image' => 'nullable|image',
'language' => 'required|string',
'topped' => 'nullable|boolean',
'type' => 'required|string|in:news,article,sales,media',
'position' => 'nullable|integer'
];
}
public function getName(): string
{
return (string) $this->get('name');
}
public function getBody(): string
{
return (string) $this->get('content');
}
public function getLanguage(): string
{
return (string) $this->get('language');
}
public function getTopped(): bool
{
return (bool) $this->get('topped');
}
public function getType(): string
{
return (string) $this->get('type');
}
public function getPosition(): int|null
{
if ($this->position) {
return $this->get('position');
} else {
if (Post::count() === 0) {
return 0;
}
return Post::max('position') + 1;
}
}
}

View File

@@ -0,0 +1,250 @@
<?php
namespace App\Http\Requests\Dashboard\Product;
use Carbon\Carbon;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Storage;
use App\Api\ImageResize;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'array',
'name.*' => 'required',
'body' => 'array',
'body.*' => 'required',
'short_body' => 'array',
'short_body.*' => 'required|max:300',
'price' => 'required|numeric|gt:price_discount',
'price_discount' => 'nullable',
'poster' => 'required|mimes:jpeg,png,jpg',
'brand_id' => 'required',
'measurement_id' => 'nullable|exists:measurements,id',
'category_id' => 'required',
'colors' => 'array|required',
'colors.*.color_id' => 'nullable',
'colors.*.sizes' => 'nullable|array',
'colors.*.sizes.*.name' => 'required',
'colors.*.sizes.*.count' => 'required',
'colors.*.screens' => 'array|required',
'colors.*.screens.*.image' => 'required|mimes:jpeg,png,jpg',
"calc" => [],
'popular' => 'nullable',
'leader_of_sales' => 'nullable',
'article_number' => 'required|unique:products,article_number'
];
}
/**
* @return mixed
*/
public function getColors()
{
return $this->get('colors');
}
/**
* @return string
*/
public function getPoster(): string
{
$folder = "uploads/posters/" . Carbon::now()->format('Y/m/d');
return (string) $this->file('poster')->store($folder);
}
/**
* @return string
*/
public function getCalc(): string|null
{
if ($this->hasFile('calc')) {
$folder = "uploads/calc/" . Carbon::now()->format('Y/m/d');
return (string) $this->file('calc')->store($folder);
}
return null;
}
public function getDataSheet()
{
if ($this->hasFile('data_sheet')) {
$folder = "uploads/datasheet/" . Carbon::now()->format('Y/m/d');
return (string) $this->file('data_sheet')->store($folder);
}
return null;
}
/**
* @return string
*/
public function getPosterThumb()
{
$url = $this->storeImageToS3($this->file('poster'));
return $url;
}
private function storeImageToS3($image): string
{
$path = '';
// first store temp file and resize it, then upload to s3
// 1 - store temp file
$tempPath = $image->store('temp', 'public');
if ($tempPath) {
// $tempFilePath = storage_path('app/public/' . $tempPath);
$image = new ImageResize();
$path = $image->resize($tempPath, 322, 'posters');
// 2 - upload to s3 or keep local
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
Storage::disk('s3')->put($path, file_get_contents($path));
unlink($path);
}
}
return $path;
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
/**
* @return array
*/
public function getBody(): array
{
return $this->get('body');
}
public function getPrice()
{
return $this->get('price');
}
public function getPriceDiscount()
{
if ($this->get('price_discount') > 0) {
return $this->get('price_discount');
}
return 0;
}
public function getPriceCredit()
{
if ($this->get('price_credit') > 0) {
return $this->get('price_credit');
}
return null;
}
/**
* @return mixed
*/
public function getCategoryID()
{
return $this->get('category_id');
}
/**
* @return string
*/
public function getSlug(): string
{
if ($this->get('slug') != 'null') {
return (string) str_slug($this->get('slug'));
}
return (string) str_slug($this->get('name')['ru']);
}
/**
* @return bool
*/
public function getPublished()
{
if ($this->get('published') == 'true') {
return true;
}
return false;
}
/**
* @return bool
*/
public function getAvailable()
{
if ($this->get('available') == 'true') {
return true;
}
return false;
}
/**
* @return int|null
*/
public function getBrandID()
{
if ($this->get('brand_id') != 0) {
return (int) $this->get('brand_id');
}
return null;
}
public function getMeasurementId()
{
if ($this->get('measurement_id') != 0) {
return (int) $this->get('measurement_id');
}
return null;
}
public function getPopular(): bool
{
return $this->get('popular');
}
public function getLeaderOfSales(): bool
{
if ($this->has('leader_of_sales')) {
if ($this->get('leader_of_sales') == 'true') {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,274 @@
<?php
namespace App\Http\Requests\Dashboard\Product;
use Carbon\Carbon;
use Illuminate\Foundation\Http\FormRequest;
use App\Api\ImageResize;
use App\Models\Product;
use Illuminate\Support\Facades\Storage;
class Update extends FormRequest
{
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'array',
'name.*' => 'required',
'body' => 'array',
'body.*' => 'required',
'short_body' => 'array',
'short_body.*' => 'required|max:300',
'price' => 'required|numeric',
'price_discount' => 'nullable',
'brand_id' => 'required',
'category_id' => 'required',
'popular' => 'nullable',
"calc" => [],
'leader_of_sales' => 'nullable',
'article_number' => 'required|unique:products,article_number,' . $this->product->id . ',id,deleted_at,NULL'
];
}
protected function getValidatorInstance()
{
$validator = parent::getValidatorInstance();
if ($this->isMethod('post')) {
$validator->sometimes('price', 'gt:price_discount', function ($input) {
return $input->price_discount > 0;
});
}
return $validator;
}
/**
* @return mixed
*/
public function getColors()
{
return $this->get('colors');
}
/**
* @return string
*/
public function getPoster(Product $product): string
{
if ($this->hasFile('poster')) {
if (env('FILESYSTEM_DISK') == 's3') {
// delete old file from s3
Storage::disk('s3')->delete($product->poster);
} else {
// delete old file
unlink($product->poster);
}
$folder = "uploads/posters/" . Carbon::now()->format('Y/m/d');
return (string) $this->file('poster')->store($folder);
}
return $product->poster;
}
/**
* @return string
*/
public function getCalc(Product $product): string|null
{
if ($this->hasFile('calc')) {
if (env('FILESYSTEM_DISK') == 's3' and $product->calc) {
// delete old file from s3
Storage::disk('s3')->delete($product->calc);
} elseif($product->calc) {
unlink($product->calc);
}
$folder = "uploads/calc/" . Carbon::now()->format('Y/m/d');
return (string) $this->file('calc')->store($folder);
}
return $product->calc;
}
public function getDataSheet(Product $product)
{
if ($this->hasFile('data_sheet')) {
if (is_file($this->get('data_sheet'))) {
unlink($this->get("data_sheet"));
}
$folder = "uploads/datasheet/" . Carbon::now()->format('Y/m/d');
return (string) $this->file('data_sheet')->store($folder);
}
return $product->data_sheet;
}
/**
* @return string
*/
public function getPosterThumb(Product $product): string
{
if ($this->hasFile('poster')) {
if (env('FILESYSTEM_DISK') == 's3') {
// delete old file from s3
Storage::disk('s3')->delete($product->poster_thumb);
} else {
// delete old file
unlink($product->poster_thumb);
}
$url = $this->storeImageToS3($this->file('poster'));
return $url;
}
return $product->poster_thumb;
}
private function storeImageToS3($image): string
{
$path = '';
// first store temp file and resize it, then upload to s3
// 1 - store temp file
$tempPath = $image->store('temp', 'public');
if ($tempPath) {
//$tempFilePath = storage_path('app/public/' . $tempPath);
$image = new ImageResize();
$path = $image->resize($tempPath, 322, 'posters');
// 2 - upload to s3 or keep local
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
Storage::disk('s3')->put($path, file_get_contents($path));
unlink($path);
}
}
return $path;
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
/**
* @return array
*/
public function getBody(): array
{
return $this->get('body');
}
public function getPrice()
{
return $this->get('price');
}
public function getPriceDiscount()
{
if ($this->get('price_discount')) {
return $this->get('price_discount');
}
return 0;
}
/**
* @return int
*/
public function getCategoryID()
{
return $this->get('category_id');
}
/**
* @return string
*/
public function getSlug(): string
{
if ($this->get('slug')) {
return (string) str_slug($this->get('slug'));
}
return (string) str_slug($this->get('name')['ru']);
}
/**
* @return bool
*/
public function getPublished()
{
if ($this->get('published') == 'true') {
return true;
}
return false;
}
/**
* @return bool
*/
public function getAvailable()
{
if ($this->get('available') == 'true') {
return true;
}
return false;
}
/**
* @return int|null
*/
public function getBrandID()
{
if ($this->get('brand_id') != 0) {
return (int) $this->get('brand_id');
}
return null;
}
/**
* @return int|null
*/
public function getMeasurementId()
{
if ($this->get('measurement_id') != 0) {
return (int) $this->get('measurement_id');
}
return null;
}
public function getPopular(): bool
{
return $this->get('popular');
}
public function getLeaderOfSales(): bool
{
if ($this->has('leader_of_sales')) {
if ($this->get('leader_of_sales') == 'true') {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Http\Requests\Dashboard\Region;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'deliveryPrice' => 'nullable|array',
'deliveryPrice.*' => 'required|array',
'deliveryPrice.*.power_id' => 'required|integer|exists:powers,id',
'deliveryPrice.*.price' => 'required|numeric',
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
public function getCash()
{
if ($this->get('cash')) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Http\Requests\Dashboard\Region;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'deliveryPrice' => 'nullable|array',
'deliveryPrice.*' => 'required|array',
'deliveryPrice.*.power_id' => 'required|integer|exists:powers,id',
'deliveryPrice.*.price' => 'required|numeric',
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
public function getCash()
{
if ($this->get('cash')) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests\Dashboard\Role;
use Illuminate\Foundation\Http\FormRequest;
class Request extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|string',
'permissions' => 'required|array'
];
}
public function getName(): string
{
return (string) $this->get('name');
}
public function getPermissions(): array
{
return (array) $this->get('permissions');
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace App\Http\Requests\Dashboard\Service;
use App\Models\Service;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name_uz' => 'required|string',
'name_ru' => 'required|string',
'image' => 'required|image',
'status' => 'required|in:published,new,soon',
'position' => 'nullable|numeric',
'is_power' => 'nullable|boolean',
'with_power' => 'nullable|boolean',
'problems' => [
'nullable',
'array',
// Only validate the array if 'with_power' is set to true (or 1)
function ($attribute, $value, $fail) {
if ($this->with_power && !is_array($value)) {
$fail($attribute . ' must be an array when with_power is present.');
}
}
],
'problems.*' => [
'nullable',
'exists:problems,id', // Validate each element of the array
]
];
}
/**
* @return array
*/
public function getName(): array
{
return [
'uz' => $this->get('name_uz'),
'ru' => $this->get('name_ru')
];
}
public function getPosition()
{
$position = $this->position;
if ($position == null) {
$service = Service::orderBy('position', 'desc')->first();
if ($service == null) {
return 1;
}
return $service->position + 1;
}
return $position;
}
public function generateSlug()
{
$slug = str_slug($this->name_ru);
$service = Service::where('type', $slug)->first();
if ($service == null) {
return $slug;
}
return $slug . '-' . time();
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Http\Requests\Dashboard\Service;
use App\Models\Service;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
*
* @return array
*/
public function rules()
{
return [
'name_uz' => 'required|string',
'name_ru' => 'required|string',
'image' => 'nullable|image',
'status' => 'required|in:published,new,soon',
'position' => 'nullable|numeric',
'is_power' => 'nullable|boolean',
];
}
/**
* @return array
*/
public function getName(): array
{
return [
'uz' => $this->get('name_uz'),
'ru' => $this->get('name_ru')
];
}
public function getPosition()
{
$position = $this->position;
if ($position == null) {
$service = Service::orderBy('position', 'desc')->first();
if ($service == null) {
return 1;
}
return $service->position + 1;
}
return $position;
}
public function generateSlug()
{
$slug = str_slug($this->name_ru);
$service = Service::where('type', $slug)->first();
if ($service == null) {
return $slug;
}
return $slug . '-' . time();
}
}

View File

@@ -0,0 +1,244 @@
<?php
namespace App\Http\Requests\Dashboard\Setting;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
* @return array
*/
public function rules()
{
return [
'title' => 'array',
'title.*' => 'required',
'keywords' => 'array',
'keywords.*' => 'required',
'description' => 'array',
'description.*' => 'required',
'phone' => 'array',
'email' => 'required',
'address' => 'array',
'address.*' => 'required',
'socials' => 'array',
'socials.*' => 'required',
'landmark' => 'array',
'landmark.*' => 'required',
'links' => 'array',
'links.*' => 'required',
'group_id' => 'nullable',
//'price_delivery' => 'required|numeric',
//'day_delivery' => 'required|numeric',
//'on_credit' => 'required'
];
}
/**
* @return mixed\
*/
public function getLandmark()
{
return $this->get('landmark');
}
/**
* @return mixed
*/
public function getPriceDelivery()
{
return $this->get('price_delivery');
}
public function getDayDelivery()
{
return $this->get('day_delivery');
}
/**
* @return mixed
*/
public function getTitle()
{
return $this->get('title');
}
/**
* @return mixed
*/
public function getKeywords()
{
return $this->get('keywords');
}
/**
* @return mixed
*/
public function getDescription()
{
return $this->get("description");
}
public function getGroupId()
{
return $this->get('group_id');
}
/**
* @return mixed
*/
public function getPhone()
{
return $this->get('phone');
}
/**
* @return string
*/
public function getEmail(): string
{
return (string) $this->get('email');
}
/**
* @return mixed
*/
public function getAddress()
{
return $this->get('address');
}
public function getLinks()
{
return $this->get('links');
}
/**
* @return mixed
*/
public function getSocials()
{
return $this->get('socials');
}
/**
* @return bool
*/
public function getOnCredit()
{
if ($this->get('on_credit') == 1) {
return true;
}
return false;
}
/**
* @return bool
*/
public function getByOneClick()
{
if ($this->get('buy_one') == 1) {
return true;
}
return false;
}
/**
* @return bool
*/
public function getNewsBlock()
{
if (!empty($this->get('permissions')['news']) && $this->get('permissions')['news'] == 1) {
return true;
}
return false;
}
/**
* @return bool
*/
public function getBrandsBlock()
{
if (!empty($this->get('permissions')['brands']) && $this->get('permissions')['brands'] == 1) {
return true;
}
return false;
}
/**
* @return bool
*/
public function getSpecialBlock()
{
if (!empty($this->get('permissions')['special_block']) && $this->get('permissions')['special_block'] == 1) {
return true;
}
return false;
}
/**
* @return bool
*/
public function getMiddleBannerBlock()
{
if (!empty($this->get('permissions')['middle_banner']) && $this->get('permissions')['middle_banner'] == 1) {
return true;
}
return false;
}
/**
* @return bool
*/
public function getLiderProductsBlock()
{
if (!empty($this->get('permissions')['lider_products']) && $this->get('permissions')['lider_products'] == 1) {
return true;
}
return false;
}
/**
* @return bool
*/
public function getNewProductsBlock()
{
if (!empty($this->get('permissions')['new_products']) && $this->get('permissions')['new_products'] == 1) {
return true;
}
return false;
}
/**
* @return bool
*/
public function getPopularProductsBlock()
{
if (!empty($this->get('permissions')['popular_products']) && $this->get('permissions')['popular_products'] == 1) {
return true;
}
return false;
}
/**
* @return bool
*/
public function getPopularCategoriesBlock()
{
if (!empty($this->get('permissions')['popular_categories']) && $this->get('permissions')['popular_categories'] == 1) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace App\Http\Requests\Dashboard\Slider;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|string',
'link' => 'nullable|string',
'language' => 'required|string',
'type' => 'required|string|in:desktop,mobile',
'image' => 'required|image',
'placement' => 'required|string|in:top,middle'
];
}
/**
* @return string
*/
public function getName(): string
{
return $this->get('name');
}
/**
* @return string
*/
public function getLink(): string
{
if ($this->get('link')) {
return $this->get('link');
}
return '#';
}
public function getLanguage(): string
{
return $this->get('language');
}
public function getType(): string
{
return $this->get('type');
}
public function getPlacement(): string
{
return $this->get('placement');
}
public function getPublished(): bool
{
if ($this->get('published')) {
return true;
}
return false;
}
public function getPosition(): int
{
return $this->get('position');
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Http\Requests\Dashboard\Slider;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|string',
'link' => 'nullable|string',
'language' => 'required|string',
'type' => 'required|string|in:desktop,mobile',
'image' => 'nullable|image',
'placement' => 'required|string|in:top,middle'
];
}
public function getName(): string
{
return $this->get('name');
}
/**
* @return string
*/
public function getLink(): string
{
if ($this->get('link')) {
return $this->get('link');
}
return '#';
}
public function getLanguage(): string
{
return $this->get('language');
}
public function getType(): string
{
return $this->get('type');
}
public function getPlacement(): string
{
return $this->get('placement');
}
public function getPublished()
{
if ($this->get('published')) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Http\Requests\Dashboard\SpecialOffer;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'description' => 'required|array',
'description.*' => 'required|string',
'link' => 'required|string',
'image' => 'required|image'
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
/**
* @return array
*/
public function getDescription(): array
{
return $this->get('description');
}
public function getLink(): string
{
return $this->get('link');
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests\Dashboard\SpecialOffer;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'name' => 'required|array',
'name.*' => 'required|string',
'description' => 'required|array',
'description.*' => 'required|string',
'link' => 'required|string',
'image' => 'nullable|image'
];
}
/**
* @return array
*/
public function getName(): array
{
return $this->get('name');
}
public function getDescription(): array
{
return $this->get('description');
}
public function getLink(): string
{
return $this->get('link');
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace App\Http\Requests\Dashboard\UsefulInfoItemRequest;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name_uz' => 'required|string',
'name_ru' => 'required|string',
'description_uz' => 'nullable|string',
'description_ru' => 'nullable|string',
'video_url' => 'nullable|string',
'link_url' => 'nullable|string',
'file' => 'nullable|file|mimes:pdf,doc,docx,xls,xlsx,ppt,pptx',
];
}
/**
* @return array
*/
public function getName(): array|null
{
if ($this->has('name_uz') && $this->has('name_ru')) {
return [
'uz' => $this->get('name_uz'),
'ru' => $this->get('name_ru')
];
}
return null;
}
public function getDescription(): array|null
{
if ($this->get('description_uz') !== null && $this->get('description_ru') !== null) {
return [
'uz' => $this->get('description_uz'),
'ru' => $this->get('description_ru')
];
}
return null;
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace App\Http\Requests\Dashboard\UsefulInfoItemRequest;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
*
* @return array
*/
public function rules()
{
return [
'name_uz' => 'required|string',
'name_ru' => 'required|string',
'description_uz' => 'nullable|string',
'description_ru' => 'nullable|string',
'video_url' => 'nullable|string',
'link_url' => 'nullable|string',
'file' => 'nullable|file|mimes:pdf,doc,docx,xls,xlsx,ppt,pptx',
];
}
/**
* @return array
*/
public function getName(): array|null
{
if ($this->has('name_uz') && $this->has('name_ru')) {
return [
'uz' => $this->get('name_uz'),
'ru' => $this->get('name_ru')
];
}
return null;
}
public function getDescription(): array|null
{
if ($this->get('description_uz') !== null && $this->get('description_ru') !== null) {
return [
'uz' => $this->get('description_uz'),
'ru' => $this->get('description_ru')
];
}
return null;
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests\Dashboard\UsefulInfoRequest;
use App\Models\UsefulInfo;
use Illuminate\Foundation\Http\FormRequest;
class Store extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name_uz' => 'required|string',
'name_ru' => 'required|string',
'image' => 'required|image',
'position' => 'nullable|integer'
];
}
/**
* @return array
*/
public function getName(): array
{
return [
'uz' => $this->get('name_uz'),
'ru' => $this->get('name_ru')
];
}
public function getPosition(): int|null
{
if ($this->position) {
return $this->get('position');
} else {
if (UsefulInfo::count() === 0) {
return 0;
}
return UsefulInfo::max('position') + 1;
}
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Http\Requests\Dashboard\UsefulInfoRequest;
use App\Models\UsefulInfo;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
*
* @return array
*/
public function rules()
{
return [
'name_uz' => 'required|string',
'name_ru' => 'required|string',
'image' => 'nullable|image',
'position' => 'nullable|integer'
];
}
/**
* @return array
*/
public function getName(): array
{
return [
'uz' => $this->get('name_uz'),
'ru' => $this->get('name_ru')
];
}
public function getPosition(): int|null
{
if ($this->position) {
return $this->get('position');
} else {
if (UsefulInfo::count() === 0) {
return 0;
}
return UsefulInfo::max('position') + 1;
}
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Requests\Dashboard\User;
use Illuminate\Foundation\Http\FormRequest;
class Create extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
if ($this->isMethod('get')) {
return [];
}
return [
'username' => 'required|string|unique:staff,username',
'role_id' => 'required|numeric',
'password' => 'required|min:6',
];
}
/**
* @return string
*/
public function getUsername(): string
{
return (string) $this->get('username');
}
/**
* @return int
*/
public function getRoleId(): int
{
return (int) $this->get('role_id');
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Dashboard\User;
use Illuminate\Foundation\Http\FormRequest;
class Edit extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
if ($this->isMethod('get')) {
return [];
}
return [
'first_name' => 'required',
'last_name' => 'required',
'gender' => 'required',
'category_id' => 'required',
'role_id' => 'required',
'birth_day' => 'required',
];
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests\Dashboard\User;
use Illuminate\Foundation\Http\FormRequest;
class Update extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->isMethod('get')) {
return [];
}
return [
'username' => 'required|string|unique:staff,username,'.$this->staff->id,
'role_id' => 'numeric',
'password' => 'nullable|min:6',
];
}
/**
* @return string
*/
public function getUsername(): string
{
return (string) $this->get('username');
}
/**
* @return int
*/
public function getRoleId(): int
{
return (int) $this->get('role_id');
}
public function getPassword(): string
{
return (string) $this->get('password');
}
}