restore composer.json, add mysqli extension
This commit is contained in:
40
app/Http/Requests/Api/Auth/Login.php
Executable file
40
app/Http/Requests/Api/Auth/Login.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Auth;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Login extends FormRequest
|
||||
{
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'phone' => str_replace(['+', '(', ')', '-', ' '], '', $this->phone),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'phone' => [
|
||||
'required',
|
||||
'string',
|
||||
'regex:/(998)(90|91|92|93|94|95|96|97|98|99|33|88)[0-9]{7}/',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPhone(): int
|
||||
{
|
||||
return (int) str_replace(['+', '(', ')', '-', ' '], '', $this->get('phone'));
|
||||
}
|
||||
}
|
||||
53
app/Http/Requests/Api/Auth/Password.php
Executable file
53
app/Http/Requests/Api/Auth/Password.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Auth;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Password extends FormRequest
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'phone' => str_replace(['+', '(', ')', '-', ' '], '', $this->phone),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'phone' => [
|
||||
'required',
|
||||
'string',
|
||||
'regex:/(998)(90|91|92|93|94|95|96|97|98|99|33|88)[0-9]{7}/',
|
||||
],
|
||||
|
||||
'password' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPhone(): int
|
||||
{
|
||||
return (int) str_replace(['+', '(', ')', '-', ' '], '', $this->get('phone'));
|
||||
}
|
||||
|
||||
public function getRemember(): bool
|
||||
{
|
||||
if ($this->get('remember')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
48
app/Http/Requests/Api/Auth/Register.php
Executable file
48
app/Http/Requests/Api/Auth/Register.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Auth;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Register extends FormRequest
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'phone' => str_replace(['+', '(', ')', '-', ' '], '', $this->phone),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'phone' => 'required|numeric',
|
||||
'password' => 'required|confirmed|min:6'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'password.confirmed' => trans('vue.login.confirmed'),
|
||||
'password.min' => trans('vue.login.min')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPhone(): int
|
||||
{
|
||||
return (int) str_replace(['+', '(', ')', '-', ' '], '', $this->get('phone'));
|
||||
}
|
||||
}
|
||||
|
||||
48
app/Http/Requests/Api/Auth/Verify.php
Executable file
48
app/Http/Requests/Api/Auth/Verify.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Auth;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Verify extends FormRequest
|
||||
{
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'phone' => str_replace(['+', '(', ')', '-', ' '], '', $this->phone),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'phone' => [
|
||||
'required',
|
||||
'string',
|
||||
'regex:/(998)(90|91|92|93|94|95|96|97|98|99|33|88)[0-9]{7}/',
|
||||
],
|
||||
'code' => 'required|numeric|min:6'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPhone(): int
|
||||
{
|
||||
return (int) str_replace(['+', '(', ')', '-', ' '], '', $this->get('phone'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCode(): int
|
||||
{
|
||||
return (int) $this->get('code');
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/Api/Card/Request.php
Executable file
32
app/Http/Requests/Api/Card/Request.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Card;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Request extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'products' => 'array|required',
|
||||
'products.*.id' => 'required',
|
||||
'products.*.count' => 'required',
|
||||
'products.*.size' => 'required',
|
||||
'products.*.color_id' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getProducts()
|
||||
{
|
||||
return $this->get('products');
|
||||
}
|
||||
}
|
||||
55
app/Http/Requests/Api/Checkout/CheckoutRequest.php
Executable file
55
app/Http/Requests/Api/Checkout/CheckoutRequest.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Checkout;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CheckoutRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'type' => 'required|in:ready_solutions,single_products',
|
||||
'delivery_type' => 'required|in:delivery,pickup',
|
||||
|
||||
'branch_id' => 'required_if:delivery_type,pickup|exists:branches,id',
|
||||
'client_type' => 'required|in:physical,legal',
|
||||
'client_information' => 'required_if:client_type,physical|array',
|
||||
'client_information.full_name' => 'required_if:client_type,physical|string',
|
||||
'client_information.phone' => 'required_if:client_type,physical|numeric',
|
||||
|
||||
'client_information.director_full_name' => 'required_if:client_type,legal|string',
|
||||
'client_information.company_name' => 'required_if:client_type,legal|string',
|
||||
'client_information.inn' => 'required_if:client_type,legal|string',
|
||||
'client_information.bank_name' => 'required_if:client_type,legal|string',
|
||||
'client_information.mfo' => 'required_if:client_type,legal|string',
|
||||
'client_information.oked' => 'required_if:client_type,legal|string',
|
||||
'client_information.payment_account' => 'required_if:client_type,legal|string',
|
||||
'client_information.address' => 'required_if:client_type,legal|string',
|
||||
'client_information.email' => 'nullable|email',
|
||||
'client_information.phone' => 'required_if:client_type,legal|numeric', //
|
||||
|
||||
'client_information.jshir' => 'required_if:client_type,physical|numeric', //
|
||||
'client_information.series' => 'required_if:client_type,physical', //
|
||||
|
||||
'address' => 'required_if:delivery_type,delivery|array',
|
||||
'address.city_id' => 'required_if:delivery_type,delivery|exists:cities,id',
|
||||
'address.address' => 'required_if:delivery_type,delivery|string',
|
||||
'address.home' => 'nullable',
|
||||
'address.landmark' => 'nullable',
|
||||
|
||||
'with_installation' => 'required_if:type,ready_solutions|boolean',
|
||||
'payment_type' => 'required|in:cash,bank,click,payme',
|
||||
'with_didox' => 'required_if:payment_type,bank|boolean',
|
||||
|
||||
'products' => 'required|array',
|
||||
'products.*.id' => 'required|exists:products,id',
|
||||
'products.*.count' => 'required|integer|min:1',
|
||||
];
|
||||
}
|
||||
}
|
||||
25
app/Http/Requests/Api/Favorites/Request.php
Executable file
25
app/Http/Requests/Api/Favorites/Request.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Favorites;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Request extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'id' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
public function getID(): int
|
||||
{
|
||||
return $this->get('id');
|
||||
}
|
||||
}
|
||||
77
app/Http/Requests/Api/Filter/Request.php
Executable file
77
app/Http/Requests/Api/Filter/Request.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Filter;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Request extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'categories' => 'nullable|array',
|
||||
|
||||
'brands' => 'nullable|array',
|
||||
'brands.*' => 'required',
|
||||
|
||||
'sizes' => 'nullable',
|
||||
//'sizes.*' => 'required',
|
||||
|
||||
'colors' => 'nullable|array',
|
||||
'colors.*' => 'required',
|
||||
|
||||
'price_from' => 'nullable|numeric',
|
||||
'price_before' => 'nullable|numeric'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getCategories()
|
||||
{
|
||||
return $this->get('categories');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getBrand()
|
||||
{
|
||||
return $this->get('brands');
|
||||
}
|
||||
|
||||
public function getSizes()
|
||||
{
|
||||
return $this->get('sizes');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getColors()
|
||||
{
|
||||
return $this->get('colors');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getPriceFrom()
|
||||
{
|
||||
return $this->get('price_from');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getPriceBefore()
|
||||
{
|
||||
return $this->get('price_before');
|
||||
}
|
||||
}
|
||||
23
app/Http/Requests/Api/Firebase/Request.php
Executable file
23
app/Http/Requests/Api/Firebase/Request.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Firebase;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Request extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'device_id' => 'required',
|
||||
'device_token' => 'required',
|
||||
'device_type' => 'required',
|
||||
'device_name' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
218
app/Http/Requests/Api/Order/Request.php
Executable file
218
app/Http/Requests/Api/Order/Request.php
Executable file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Order;
|
||||
|
||||
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 [
|
||||
'phone' => 'required|min:9|max:9',
|
||||
'first_name' => 'required',
|
||||
|
||||
'type_delivery' => 'required',
|
||||
// 'shipment_date' => 'nullable',
|
||||
|
||||
// 'city' => 'nullable',
|
||||
// 'region' => 'nullable',
|
||||
// 'street' => 'nullable',
|
||||
// 'floor' => 'nullable',
|
||||
// 'apartment' => 'nullable',
|
||||
// 'entrance' => 'nullable',
|
||||
|
||||
'payment_type' => 'required',
|
||||
'comment' => 'nullable',
|
||||
// 'branch_id' => 'nullable',
|
||||
|
||||
'products' => 'array|required',
|
||||
'products.*.id' => 'required',
|
||||
'products.*.count' => 'required',
|
||||
'products.*.size' => 'required',
|
||||
'products.*.color_id' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getValidatorInstance() {
|
||||
$validator = parent::getValidatorInstance();
|
||||
|
||||
if ($this->isMethod('post')) {
|
||||
|
||||
$validator->sometimes('branch_id', 'required', function($input) {
|
||||
return $input->type_delivery == 2;
|
||||
});
|
||||
|
||||
$validator->sometimes('shipment_date', 'required', function($input) {
|
||||
return $input->type_delivery == 2;
|
||||
});
|
||||
|
||||
$validator->sometimes('city', 'required', function($input) {
|
||||
return $input->type_delivery == 1;
|
||||
});
|
||||
|
||||
$validator->sometimes('region', 'required', function($input) {
|
||||
return $input->type_delivery == 1;
|
||||
});
|
||||
|
||||
$validator->sometimes('street', 'required', function($input) {
|
||||
return $input->type_delivery == 1;
|
||||
});
|
||||
}
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPhone(): int
|
||||
{
|
||||
return (int ) 998 . $this->get('phone');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstName(): string
|
||||
{
|
||||
return (string) $this->get('first_name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getBranchID()
|
||||
{
|
||||
if ($this->get('branch_id')) {
|
||||
return $this->get('branch_id');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTypeDelivery(): int
|
||||
{
|
||||
return (int) $this->get('type_delivery');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getShipmentDate()
|
||||
{
|
||||
if ($this->get('shipment_date')) {
|
||||
return $this->get('shipment_date');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCity()
|
||||
{
|
||||
if ($this->get('city')) {
|
||||
return (string) $this->get('city');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRegion()
|
||||
{
|
||||
if ($this->get('region')) {
|
||||
return (string) $this->get('region');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getStreet()
|
||||
{
|
||||
if ($this->get('street')) {
|
||||
return (string) $this->get('street');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFloor()
|
||||
{
|
||||
if ($this->get('floor')) {
|
||||
return (string) $this->get('floor');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApartment()
|
||||
{
|
||||
if ($this->get('apartment')) {
|
||||
return (string) $this->get('apartment');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEntrance()
|
||||
{
|
||||
if ($this->get('entrance')) {
|
||||
return (string) $this->get('entrance');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPaymentType()
|
||||
{
|
||||
return (string) $this->get('payment_type');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComment(): string
|
||||
{
|
||||
return (string) $this->get('comment');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getProducts()
|
||||
{
|
||||
return $this->get('products');
|
||||
}
|
||||
}
|
||||
25
app/Http/Requests/Api/Partner/PartnerRequest.php
Executable file
25
app/Http/Requests/Api/Partner/PartnerRequest.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Partner;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PartnerRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'partner_id' => 'required|exists:partners,id',
|
||||
'phone' => 'required|numeric',
|
||||
'full_name' => 'required',
|
||||
'comment' => 'nullable',
|
||||
'city_id' => 'required|exists:cities,id',
|
||||
'price' => 'nullable',
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Requests/Api/Service/ServiceRequest.php
Executable file
36
app/Http/Requests/Api/Service/ServiceRequest.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\Service;
|
||||
|
||||
use App\Models\Service;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ServiceRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$service = Service::find($this->service_id);
|
||||
|
||||
return [
|
||||
'service_id' => 'required|exists:services,id',
|
||||
'power_id' => [
|
||||
Rule::requiredIf(function () use ($service) {
|
||||
// If service exists and is_power is true, require power_id
|
||||
return $service && $service->is_power;
|
||||
}),
|
||||
'nullable', // Allow null if the condition is false
|
||||
'exists:powers,id' // Validate the power_id exists in the powers table
|
||||
],
|
||||
'city_id' => 'required|exists:cities,id',
|
||||
'phone' => 'required|numeric',
|
||||
'full_name' => 'required',
|
||||
'comment' => 'nullable',
|
||||
];
|
||||
}
|
||||
}
|
||||
98
app/Http/Requests/Api/User/Update.php
Executable file
98
app/Http/Requests/Api/User/Update.php
Executable file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\User;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Update extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'gender' => 'required',
|
||||
'birth_day' => 'nullable',
|
||||
'avatar' => 'nullable|mimes:jpeg,png,jpg',
|
||||
'category' => 'required',
|
||||
|
||||
'language' => 'required',
|
||||
'notification' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstName(): string
|
||||
{
|
||||
return (string) $this->get('first_name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastName(): string
|
||||
{
|
||||
return (string) $this->get('last_name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getGender(): bool
|
||||
{
|
||||
return $this->get('gender') == 'men' ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBirthDay(): string
|
||||
{
|
||||
return (string) $this->get('birth_day');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|string|null
|
||||
*/
|
||||
public function getAvatar()
|
||||
{
|
||||
if ($this->hasFile('avatar')) {
|
||||
$path = "uploads/avatar/". Carbon::now()->format('Y/m/d');
|
||||
return $this->file('avatar')->store($path);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCategory(): int
|
||||
{
|
||||
return (int) $this->get('category');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getNotification(): bool
|
||||
{
|
||||
return $this->get('notification');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLanguages(): string
|
||||
{
|
||||
return (string) $this->get('language');
|
||||
}
|
||||
}
|
||||
24
app/Http/Requests/Comment/StoreRequest.php
Executable file
24
app/Http/Requests/Comment/StoreRequest.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Comment;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'star' => 'required',
|
||||
'body' => 'required',
|
||||
'first_name' => 'required'
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Confirm.php
Executable file
30
app/Http/Requests/Confirm.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Confirm extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
64
app/Http/Requests/Dashboard/Branch/Request.php
Executable file
64
app/Http/Requests/Dashboard/Branch/Request.php
Executable 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');
|
||||
}
|
||||
}
|
||||
36
app/Http/Requests/Dashboard/Brand/Store.php
Executable file
36
app/Http/Requests/Dashboard/Brand/Store.php
Executable 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');
|
||||
}
|
||||
|
||||
}
|
||||
33
app/Http/Requests/Dashboard/Brand/Update.php
Executable file
33
app/Http/Requests/Dashboard/Brand/Update.php
Executable 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');
|
||||
}
|
||||
}
|
||||
104
app/Http/Requests/Dashboard/Category/Request.php
Executable file
104
app/Http/Requests/Dashboard/Category/Request.php
Executable 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;
|
||||
}
|
||||
}
|
||||
113
app/Http/Requests/Dashboard/Category/Update.php
Executable file
113
app/Http/Requests/Dashboard/Category/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
39
app/Http/Requests/Dashboard/City/Store.php
Executable file
39
app/Http/Requests/Dashboard/City/Store.php
Executable 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');
|
||||
}
|
||||
}
|
||||
39
app/Http/Requests/Dashboard/City/Update.php
Executable file
39
app/Http/Requests/Dashboard/City/Update.php
Executable 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');
|
||||
}
|
||||
}
|
||||
36
app/Http/Requests/Dashboard/Color/Request.php
Executable file
36
app/Http/Requests/Dashboard/Color/Request.php
Executable 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');
|
||||
}
|
||||
}
|
||||
58
app/Http/Requests/Dashboard/Compilation/Store.php
Executable file
58
app/Http/Requests/Dashboard/Compilation/Store.php
Executable 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;
|
||||
}
|
||||
}
|
||||
55
app/Http/Requests/Dashboard/Compilation/Update.php
Executable file
55
app/Http/Requests/Dashboard/Compilation/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
42
app/Http/Requests/Dashboard/Currency/Store.php
Executable file
42
app/Http/Requests/Dashboard/Currency/Store.php
Executable 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');
|
||||
}
|
||||
}
|
||||
21
app/Http/Requests/Dashboard/File/Store.php
Executable file
21
app/Http/Requests/Dashboard/File/Store.php
Executable 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'
|
||||
];
|
||||
}
|
||||
}
|
||||
163
app/Http/Requests/Dashboard/Order/Update.php
Executable file
163
app/Http/Requests/Dashboard/Order/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
44
app/Http/Requests/Dashboard/Page/Store.php
Executable file
44
app/Http/Requests/Dashboard/Page/Store.php
Executable 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');
|
||||
}
|
||||
|
||||
}
|
||||
43
app/Http/Requests/Dashboard/Page/Update.php
Executable file
43
app/Http/Requests/Dashboard/Page/Update.php
Executable 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');
|
||||
}
|
||||
}
|
||||
47
app/Http/Requests/Dashboard/Partner/Store.php
Executable file
47
app/Http/Requests/Dashboard/Partner/Store.php
Executable 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')
|
||||
];
|
||||
}
|
||||
}
|
||||
47
app/Http/Requests/Dashboard/Partner/Update.php
Executable file
47
app/Http/Requests/Dashboard/Partner/Update.php
Executable 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')
|
||||
];
|
||||
}
|
||||
}
|
||||
68
app/Http/Requests/Dashboard/Post/Store.php
Executable file
68
app/Http/Requests/Dashboard/Post/Store.php
Executable 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
68
app/Http/Requests/Dashboard/Post/Update.php
Executable file
68
app/Http/Requests/Dashboard/Post/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
250
app/Http/Requests/Dashboard/Product/Store.php
Executable file
250
app/Http/Requests/Dashboard/Product/Store.php
Executable 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;
|
||||
}
|
||||
}
|
||||
274
app/Http/Requests/Dashboard/Product/Update.php
Executable file
274
app/Http/Requests/Dashboard/Product/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
46
app/Http/Requests/Dashboard/Region/Store.php
Executable file
46
app/Http/Requests/Dashboard/Region/Store.php
Executable 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;
|
||||
}
|
||||
}
|
||||
46
app/Http/Requests/Dashboard/Region/Update.php
Executable file
46
app/Http/Requests/Dashboard/Region/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
35
app/Http/Requests/Dashboard/Role/Request.php
Executable file
35
app/Http/Requests/Dashboard/Role/Request.php
Executable 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');
|
||||
}
|
||||
}
|
||||
77
app/Http/Requests/Dashboard/Service/Store.php
Executable file
77
app/Http/Requests/Dashboard/Service/Store.php
Executable 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();
|
||||
}
|
||||
}
|
||||
61
app/Http/Requests/Dashboard/Service/Update.php
Executable file
61
app/Http/Requests/Dashboard/Service/Update.php
Executable 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();
|
||||
}
|
||||
}
|
||||
244
app/Http/Requests/Dashboard/Setting/Update.php
Executable file
244
app/Http/Requests/Dashboard/Setting/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
80
app/Http/Requests/Dashboard/Slider/Store.php
Executable file
80
app/Http/Requests/Dashboard/Slider/Store.php
Executable 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');
|
||||
}
|
||||
|
||||
}
|
||||
69
app/Http/Requests/Dashboard/Slider/Update.php
Executable file
69
app/Http/Requests/Dashboard/Slider/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
51
app/Http/Requests/Dashboard/SpecialOffer/Store.php
Executable file
51
app/Http/Requests/Dashboard/SpecialOffer/Store.php
Executable 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');
|
||||
}
|
||||
|
||||
}
|
||||
47
app/Http/Requests/Dashboard/SpecialOffer/Update.php
Executable file
47
app/Http/Requests/Dashboard/SpecialOffer/Update.php
Executable 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');
|
||||
}
|
||||
}
|
||||
53
app/Http/Requests/Dashboard/UsefulInfoItemRequest/Store.php
Executable file
53
app/Http/Requests/Dashboard/UsefulInfoItemRequest/Store.php
Executable 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;
|
||||
}
|
||||
}
|
||||
52
app/Http/Requests/Dashboard/UsefulInfoItemRequest/Update.php
Executable file
52
app/Http/Requests/Dashboard/UsefulInfoItemRequest/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
47
app/Http/Requests/Dashboard/UsefulInfoRequest/Store.php
Executable file
47
app/Http/Requests/Dashboard/UsefulInfoRequest/Store.php
Executable 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
app/Http/Requests/Dashboard/UsefulInfoRequest/Update.php
Executable file
46
app/Http/Requests/Dashboard/UsefulInfoRequest/Update.php
Executable 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
app/Http/Requests/Dashboard/User/Create.php
Executable file
42
app/Http/Requests/Dashboard/User/Create.php
Executable 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');
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Dashboard/User/Edit.php
Executable file
31
app/Http/Requests/Dashboard/User/Edit.php
Executable 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',
|
||||
];
|
||||
}
|
||||
}
|
||||
47
app/Http/Requests/Dashboard/User/Update.php
Executable file
47
app/Http/Requests/Dashboard/User/Update.php
Executable 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');
|
||||
}
|
||||
}
|
||||
46
app/Http/Requests/LoginRequest.php
Executable file
46
app/Http/Requests/LoginRequest.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'phone' => str_replace(['+', '(', ')', '-', ' '], '', $this->phone),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
if ($this->isMethod('get')) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
'username' => [
|
||||
'required',
|
||||
'string',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/Site/Cart/CartStoreRequest.php
Executable file
33
app/Http/Requests/Site/Cart/CartStoreRequest.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Site\Cart;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CartStoreRequest extends FormRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'product_id' => 'required|exists:products,id',
|
||||
'count' => 'required|numeric'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
if ($this->get('size')) {
|
||||
return $this->get('size');
|
||||
}
|
||||
|
||||
return $this->get('size');
|
||||
}
|
||||
}
|
||||
90
app/Http/Requests/Site/Checkout/StoreRequest.php
Executable file
90
app/Http/Requests/Site/Checkout/StoreRequest.php
Executable file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Site\Checkout;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
if ($this->isMethod('post')) {
|
||||
return [
|
||||
'delivery_type' => 'required',
|
||||
'payment_type' => 'required|in:cash,payme,apelsin,click,uzcard,humo',
|
||||
'products' => 'array|required',
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getValidatorInstance() {
|
||||
$validator = parent::getValidatorInstance();
|
||||
|
||||
if ($this->isMethod('post')) {
|
||||
|
||||
$validator->sometimes('address.region_id', 'required', function($input) {
|
||||
return $input->delivery_type == 'delivery';
|
||||
});
|
||||
|
||||
$validator->sometimes('address.city_id', 'required', function($input) {
|
||||
return $input->delivery_type == 'delivery';
|
||||
});
|
||||
|
||||
$validator->sometimes('address.address', 'required', function($input) {
|
||||
return $input->delivery_type == 'delivery';
|
||||
});
|
||||
|
||||
$validator->sometimes('address.first_name', 'required', function($input) {
|
||||
return $input->delivery_type == 'delivery';
|
||||
});
|
||||
}
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPaymentStatus()
|
||||
{
|
||||
if ($this->get('payment_type') === 'cash') {
|
||||
return 'cash';
|
||||
}
|
||||
|
||||
return 'waiting';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getShipmentDate()
|
||||
{
|
||||
if ($this->get('shipment_date')) {
|
||||
return $this->get('shipment_date');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getBranchID()
|
||||
{
|
||||
if ($this->get('branch_id')) {
|
||||
return $this->get('branch_id');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
23
app/Http/Requests/Site/Comment/CommentCreateRequest.php
Executable file
23
app/Http/Requests/Site/Comment/CommentCreateRequest.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Site\Comment;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CommentCreateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'first_name' => 'required|string',
|
||||
'body' => 'required|string',
|
||||
'star' => 'required|numeric',
|
||||
'product_id' => 'required|numeric|exists:products,id'
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Http/Requests/Site/Feedback/Create.php
Executable file
27
app/Http/Requests/Site/Feedback/Create.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Site\Feedback;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Create extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string',
|
||||
'phone' => [
|
||||
'required',
|
||||
'string',
|
||||
'regex:/(\+998) (90|91|92|93|94|95|96|97|98|99|33|88) [0-9]{3} [0-9]{2} [0-9]{2}/',
|
||||
],
|
||||
'message' => 'required|string'
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Requests/Site/Product/BuyOneClickRequest.php
Executable file
37
app/Http/Requests/Site/Product/BuyOneClickRequest.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Site\Product;
|
||||
|
||||
use App\Rules\Auth\Phone;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class BuyOneClickRequest extends FormRequest
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'phone' => str_replace(['+', '(', ')', '-', ' '], '', $this->phone),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'product_id' => 'required',
|
||||
'phone' => [
|
||||
'required',
|
||||
'string',
|
||||
'regex:/(998)(90|91|92|93|94|95|96|97|98|99)[0-9]{7}/',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
52
app/Http/Requests/Site/Product/CreditRequest.php
Executable file
52
app/Http/Requests/Site/Product/CreditRequest.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Site\Product;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreditRequest extends FormRequest
|
||||
{
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'phone' => str_replace(['+', '(', ')', '-', ' '], '', $this->phone),
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
if ($this->isMethod('get')) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
'phone' => [
|
||||
'required',
|
||||
'string',
|
||||
'regex:/(998)(90|91|92|93|94|95|96|97|98|99|33|88)[0-9]{7}/',
|
||||
],
|
||||
'code' => 'required|numeric|min:6'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPhone(): int
|
||||
{
|
||||
return (int) str_replace(['+', '(', ')', '-', ' '], '', $this->get('phone'));
|
||||
}
|
||||
}
|
||||
26
app/Http/Requests/Site/Profile/ChangePasswordRequest.php
Executable file
26
app/Http/Requests/Site/Profile/ChangePasswordRequest.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Site\Profile;
|
||||
|
||||
|
||||
use App\Rules\MatchOldPassword;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ChangePasswordRequest extends FormRequest
|
||||
{
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'current_password' => ['required', new MatchOldPassword],
|
||||
'password' => 'required|confirmed|min:6'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'password.confirmed' => trans('vue.login.confirmed'),
|
||||
'password.min' => trans('vue.login.min')
|
||||
];
|
||||
}
|
||||
}
|
||||
21
app/Http/Requests/Site/Profile/Update.php
Executable file
21
app/Http/Requests/Site/Profile/Update.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Site\Profile;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Update extends FormRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'first_name' => 'required'
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user