add change avatar
This commit is contained in:
@@ -25,7 +25,7 @@ class LoginRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'username' => 'required|exists:users,username',
|
||||
'username' => 'required|exists:users,username',
|
||||
'password' => 'required|string',
|
||||
'telephone_id' => 'required|string'
|
||||
];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
28
app/Http/Requests/Profile/ChangeAvatarRequest.php
Normal file
28
app/Http/Requests/Profile/ChangeAvatarRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Profile;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ChangeAvatarRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'avatar' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Profile;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
Reference in New Issue
Block a user