v2 first commit
This commit is contained in:
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class Customer extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$email = '';
|
||||
$required = '';
|
||||
|
||||
// Get company id
|
||||
$company_id = $this->request->get('company_id');
|
||||
|
||||
// Check if store or update
|
||||
if ($this->getMethod() == 'PATCH') {
|
||||
$id = $this->customer->getAttribute('id');
|
||||
} else {
|
||||
$id = null;
|
||||
}
|
||||
|
||||
if (!empty($this->request->get('create_user')) && empty($this->request->get('user_id'))) {
|
||||
$required = 'required|';
|
||||
}
|
||||
|
||||
if (!empty($this->request->get('email'))) {
|
||||
$email = 'email|unique:customers,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL';
|
||||
}
|
||||
|
||||
return [
|
||||
'user_id' => 'nullable|integer',
|
||||
'name' => 'required|string',
|
||||
'email' => $email,
|
||||
'currency_code' => 'required|string|currency',
|
||||
'password' => $required . 'confirmed',
|
||||
'enabled' => 'integer|boolean',
|
||||
];
|
||||
}
|
||||
}
|
@ -2,10 +2,10 @@
|
||||
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
use Date;
|
||||
|
||||
class Invoice extends Request
|
||||
class Invoice extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
@ -26,13 +26,19 @@ class Invoice extends Request
|
||||
{
|
||||
// Check if store or update
|
||||
if ($this->getMethod() == 'PATCH') {
|
||||
$id = $this->invoice->getAttribute('id');
|
||||
$id = is_numeric($this->invoice) ? $this->invoice : $this->invoice->getAttribute('id');
|
||||
} else {
|
||||
$id = null;
|
||||
}
|
||||
|
||||
$attachment = 'nullable';
|
||||
|
||||
if ($this->request->get('attachment', null)) {
|
||||
$attachment = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
|
||||
}
|
||||
|
||||
// Get company id
|
||||
$company_id = $this->request->get('company_id');
|
||||
$company_id = $this->request->get('company_id', 1);
|
||||
|
||||
return [
|
||||
'invoice_number' => 'required|string|unique:invoices,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',
|
||||
@ -40,16 +46,16 @@ class Invoice extends Request
|
||||
'invoiced_at' => 'required|date_format:Y-m-d H:i:s',
|
||||
'due_at' => 'required|date_format:Y-m-d H:i:s',
|
||||
'amount' => 'required',
|
||||
'item.*.name' => 'required|string',
|
||||
'item.*.quantity' => 'required',
|
||||
'item.*.price' => 'required|amount',
|
||||
'item.*.currency' => 'required|string|currency',
|
||||
'items.*.name' => 'required|string',
|
||||
'items.*.quantity' => 'required',
|
||||
'items.*.price' => 'required|amount',
|
||||
'items.*.currency' => 'required|string|currency',
|
||||
'currency_code' => 'required|string|currency',
|
||||
'currency_rate' => 'required',
|
||||
'customer_id' => 'required|integer',
|
||||
'customer_name' => 'required|string',
|
||||
'contact_id' => 'required|integer',
|
||||
'contact_name' => 'required|string',
|
||||
'category_id' => 'required|integer',
|
||||
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
|
||||
'attachment' => $attachment,
|
||||
];
|
||||
}
|
||||
|
||||
@ -68,11 +74,11 @@ class Invoice extends Request
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'item.*.name.required' => trans('validation.required', ['attribute' => mb_strtolower(trans('general.name'))]),
|
||||
'item.*.quantity.required' => trans('validation.required', ['attribute' => mb_strtolower(trans('invoices.quantity'))]),
|
||||
'item.*.price.required' => trans('validation.required', ['attribute' => mb_strtolower(trans('invoices.price'))]),
|
||||
'item.*.currency.required' => trans('validation.custom.invalid_currency'),
|
||||
'item.*.currency.string' => trans('validation.custom.invalid_currency'),
|
||||
'items.*.name.required' => trans('validation.required', ['attribute' => mb_strtolower(trans('general.name'))]),
|
||||
'items.*.quantity.required' => trans('validation.required', ['attribute' => mb_strtolower(trans('invoices.quantity'))]),
|
||||
'items.*.price.required' => trans('validation.required', ['attribute' => mb_strtolower(trans('invoices.price'))]),
|
||||
'items.*.currency.required' => trans('validation.custom.invalid_currency'),
|
||||
'items.*.currency.string' => trans('validation.custom.invalid_currency'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class InvoiceAddItem extends Request
|
||||
class InvoiceAddItem extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class InvoiceHistory extends Request
|
||||
class InvoiceHistory extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class InvoiceItem extends Request
|
||||
class InvoiceItem extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Date;
|
||||
|
||||
class InvoicePayment extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'account_id' => 'required|integer',
|
||||
'paid_at' => 'required|date_format:Y-m-d H:i:s',
|
||||
'amount' => 'required|amount',
|
||||
'currency_code' => 'required|string|currency',
|
||||
'payment_method' => 'required|string',
|
||||
'attachment' => 'mimes:jpeg,jpg,png,pdf',
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator($validator)
|
||||
{
|
||||
if ($validator->errors()->count()) {
|
||||
$paid_at = Date::parse($this->request->get('paid_at'))->format('Y-m-d');
|
||||
|
||||
$this->request->set('paid_at', $paid_at);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class InvoiceTotal extends Request
|
||||
class InvoiceTotal extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Date;
|
||||
|
||||
class Revenue extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'account_id' => 'required|integer',
|
||||
'paid_at' => 'required|date_format:Y-m-d H:i:s',
|
||||
'amount' => 'required|amount',
|
||||
'currency_code' => 'required|string|currency',
|
||||
'currency_rate' => 'required',
|
||||
'customer_id' => 'nullable|integer',
|
||||
'category_id' => 'required|integer',
|
||||
'payment_method' => 'required|string',
|
||||
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator($validator)
|
||||
{
|
||||
if ($validator->errors()->count()) {
|
||||
$paid_at = Date::parse($this->request->get('paid_at'))->format('Y-m-d');
|
||||
|
||||
$this->request->set('paid_at', $paid_at);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user