add change avatar
This commit is contained in:
@@ -14,12 +14,7 @@ class UpdateRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
$operator_telephone_id = auth()->user()->telephone_id;
|
||||
|
||||
if ($operator_telephone_id == $this->call->telephone_id) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return auth()->user()->telephone_id == $this->call->telephone_id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +35,12 @@ class UpdateRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
function (Validator $validator) {
|
||||
if ($this->somethingElseIsInvalid()) {
|
||||
$condition = Category::query()->where([
|
||||
['category_id', '=', $this->category_id],
|
||||
['subcategory_id', '=', $this->subcategory_id]
|
||||
])->exists();
|
||||
|
||||
if (!$condition) {
|
||||
$validator->errors()->add(
|
||||
'category',
|
||||
__('messages.combination_of_category_and_subcategory_does_not_exist')
|
||||
@@ -49,19 +49,4 @@ class UpdateRequest extends FormRequest
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
private function somethingElseIsInvalid(): bool
|
||||
{
|
||||
$category_id = $this->category_id;
|
||||
$subcategory_id = $this->subcategory_id;
|
||||
|
||||
if ($category_id && $subcategory_id) {
|
||||
return !Category::query()->where([
|
||||
['category_id', $category_id],
|
||||
['subcategory_id', $subcategory_id]
|
||||
])->exists();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user