Add Module Branch and Currency
This commit is contained in:
40
app/Http/Requests/BranchRequest.php
Normal file
40
app/Http/Requests/BranchRequest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Basicdata\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class BranchRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules()
|
||||
: array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:255',
|
||||
'status' => 'nullable|boolean',
|
||||
'authorized_at' => 'nullable|datetime',
|
||||
'authorized_status' => 'nullable|string|max:1',
|
||||
'authorized_by' => 'nullable|exists:users,id',
|
||||
];
|
||||
|
||||
if ($this->method() == 'PUT') {
|
||||
$rules['code'] = 'required|string|max:3|unique:branches,code,' . $this->id;
|
||||
} else {
|
||||
$rules['code'] = 'required|string|max:3|unique:branches,code';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize()
|
||||
: bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
41
app/Http/Requests/CurrencyRequest.php
Normal file
41
app/Http/Requests/CurrencyRequest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Basicdata\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CurrencyRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules()
|
||||
: array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:255',
|
||||
'decimal_places' => 'nullable|integer|between:0,3',
|
||||
'status' => 'nullable|boolean',
|
||||
'authorized_at' => 'nullable|datetime',
|
||||
'authorized_status' => 'nullable|string|max:1',
|
||||
'authorized_by' => 'nullable|exists:users,id',
|
||||
];
|
||||
|
||||
if ($this->method() == 'PUT') {
|
||||
$rules['code'] = 'required|string|max:3|unique:currencies,code,' . $this->id;
|
||||
} else {
|
||||
$rules['code'] = 'required|string|max:3|unique:currencies,code';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize()
|
||||
: bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user