api settings

This commit is contained in:
Kerim 2023-07-29 16:23:28 +05:00
parent 325aecc0e0
commit f196747335
1 changed files with 18 additions and 21 deletions

View File

@ -126,8 +126,21 @@ class ProductsAPIController extends Controller
$rules = [
'name_ru' => 'required',
'name_en' => 'required',
// 'name_en' => 'required',
'name_tm' => 'required',
'price' => 'required|numeric',
'place' => 'required',
'description_tm' => 'required',
'description_ru' => 'required',
'old_img' => 'array',
'new_img' => 'array',
// allowed only jpg & png files with size <= 1024
'new_img.*' => 'mimes:jpg,png|max:1024',
'category_id' => [
'required',
'exists:tps_birzha_categories,id',
@ -139,20 +152,7 @@ class ProductsAPIController extends Controller
}
}
],
// 'mark' => 'required',
// 'manufacturer' => 'required',
// 'country' => 'required',
// 'market_type' => 'required|in:in,out',
// if product is being edited - not added
'productForEditing' => [
// validation for product deleted_at field - it should
// be null, means it should not be deleted (exists rule not working)
function ($attribute, $value, $fail) {
$p = Product::find($value);
if(!$p) $fail(":attribute is invalid");
}
]
];
$validator = $this->validateForm($data, $rules);
@ -183,17 +183,14 @@ class ProductsAPIController extends Controller
$product->name = $data['name_tm'];
// Sets a single translated attribute for a language
$product->setAttributeTranslated('name', $data['name_ru'], 'ru');
$product->setAttributeTranslated('name', $data['name_en'], 'en');
// $product->setAttributeTranslated('name', $data['name_en'], 'en');
// Sets a single translated attribute for a language
$product->setAttributeTranslated('slug', \Str::slug($data['name_ru'],'-'), 'ru');
$product->setAttributeTranslated('slug', \Str::slug($data['name_en'],'-'), 'en');
// $product->setAttributeTranslated('slug', \Str::slug($data['name_en'],'-'), 'en');
$product->slug = \Str::slug($data['name_tm'],'-');
$product->status = 'draft';
// $product->mark = $data['mark'];
// $product->manufacturer = $data['manufacturer'];
// $product->country = $data['country'];
// $product->market_type = $data['market_type'];
$product->vendor_id = \JWTAuth::parseToken()->authenticate()->id;
@ -226,7 +223,7 @@ class ProductsAPIController extends Controller
'price' => 'required|numeric',
'place' => 'required',
'description_tm' => 'required',
'description_en' => 'required',
// 'description_en' => 'required',
'description_ru' => 'required',
'payment_term_id' => [
'required',