remove compose file to another repo
This commit is contained in:
40
app/Http/Requests/Admin/StoreRequest.php
Normal file
40
app/Http/Requests/Admin/StoreRequest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest 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, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'full_name' => 'required|max:255|string',
|
||||
'username' => 'required|unique:users,username|string',
|
||||
'position' => 'required',
|
||||
'gender' => 'required|in:male,female',
|
||||
'national_id' => 'required|digits:10|unique:users,national_id',
|
||||
'phone_number' => 'required|numeric|digits:11|unique:users,phone_number|regex:/^09\d{9}$/',
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'password' => 'required|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:8',
|
||||
'permissions' => 'required|exists:permissions,id',
|
||||
'avatar' => 'mimes:png,jpg,pdf|max:2048',
|
||||
'email' => 'email|unique:users,email',
|
||||
'telephone_id' => 'required|string|unique:users,telephone_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
45
app/Http/Requests/Admin/UpdateRequest.php
Normal file
45
app/Http/Requests/Admin/UpdateRequest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateRequest 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, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'full_name' => 'required|max:255|string',
|
||||
'username' => ['required', 'string', Rule::unique('users', 'username')->ignore($this->user->id)],
|
||||
'position' => 'required',
|
||||
'gender' => 'required|in:male,female',
|
||||
'national_id' => ['required', 'digits:10', Rule::unique('users', 'national_id')->ignore($this->user->id)],
|
||||
'phone_number' => ['required',
|
||||
'numeric',
|
||||
'digits:11',
|
||||
Rule::unique('users', 'phone_number')->ignore($this->user->id),
|
||||
'regex:/^09\d{9}$/'
|
||||
],
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'permissions' => 'required|exists:permissions,id',
|
||||
'avatar' => 'mimes:png,jpg,pdf|max:2048',
|
||||
'email' => ['email', Rule::unique('users', 'email')->ignore($this->user->id)],
|
||||
'telephone_id' => ['required', 'string', Rule::unique('users', 'telephone_id')->ignore($this->user->id)]
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Auth/LoginRequest.php
Normal file
30
app/Http/Requests/Auth/LoginRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LoginRequest 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, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'username' => 'required|exists:users,username',
|
||||
'password' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Call/ListRequest.php
Normal file
30
app/Http/Requests/Call/ListRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Call;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ListRequest 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, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'phone_number' => 'regex:/^09\d{9}$/',
|
||||
'size' => 'integer'
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Call/StoreRequest.php
Normal file
30
app/Http/Requests/Call/StoreRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Call;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest 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, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'extension' => 'required|string|exists:users,telephone_id',
|
||||
'caller_id' => 'required|numeric|regex:/^09\d{9}$/',
|
||||
];
|
||||
}
|
||||
}
|
||||
67
app/Http/Requests/Call/UpdateRequest.php
Normal file
67
app/Http/Requests/Call/UpdateRequest.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Call;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
$operator_telephone_id = auth()->user()->telephone_id;
|
||||
|
||||
if ($operator_telephone_id == $this->call->telephone_id) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'category_id' => 'required|integer',
|
||||
'subcategory_id' => 'required|integer',
|
||||
'description' => 'string',
|
||||
];
|
||||
}
|
||||
|
||||
public function after(): array
|
||||
{
|
||||
return [
|
||||
function (Validator $validator) {
|
||||
if ($this->somethingElseIsInvalid()) {
|
||||
$validator->errors()->add(
|
||||
'category',
|
||||
__('messages.combination_of_category_and_subcategory_does_not_exist')
|
||||
);
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
29
app/Http/Requests/ChangePasswordRequest.php
Normal file
29
app/Http/Requests/ChangePasswordRequest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ChangePasswordRequest 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 [
|
||||
'current_password' => 'required|min:8|max:255',
|
||||
'new_password' => 'required|confirmed|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:8|max:255',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user