v2 first commit
This commit is contained in:
31
app/Http/Requests/Common/BulkAction.php
Normal file
31
app/Http/Requests/Common/BulkAction.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class BulkAction extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 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 [
|
||||
'handle' => 'required|string',
|
||||
'selected' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
@ -23,12 +23,18 @@ class Company extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$logo = 'nullable';
|
||||
|
||||
if ($this->request->get('logo', null)) {
|
||||
$logo = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
|
||||
}
|
||||
|
||||
return [
|
||||
'domain' => 'required|string',
|
||||
'company_name' => 'required|string',
|
||||
'company_email' => 'required|email',
|
||||
'company_logo' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
|
||||
'default_currency' => 'required|string',
|
||||
'name' => 'required|string',
|
||||
'email' => 'required|email',
|
||||
'currency' => 'required|string',
|
||||
'domain' => 'nullable|string',
|
||||
'logo' => $logo,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
58
app/Http/Requests/Common/Contact.php
Normal file
58
app/Http/Requests/Common/Contact.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class Contact extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 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 = '';
|
||||
|
||||
$type = $this->request->get('type', 'customer');
|
||||
$company_id = $this->request->get('company_id');
|
||||
|
||||
// Check if store or update
|
||||
if ($this->getMethod() == 'PATCH') {
|
||||
$id = is_numeric($this->$type) ? $this->$type : $this->$type->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:contacts,NULL,' . $id . ',id,company_id,' . $company_id . ',type,' . $type . ',deleted_at,NULL';
|
||||
}
|
||||
|
||||
return [
|
||||
'type' => 'required|string',
|
||||
'name' => 'required|string',
|
||||
'email' => $email,
|
||||
'user_id' => 'integer|nullable',
|
||||
'currency_code' => 'required|string|currency',
|
||||
'password' => $required . 'confirmed',
|
||||
'enabled' => 'integer|boolean',
|
||||
];
|
||||
}
|
||||
}
|
31
app/Http/Requests/Common/Dashboard.php
Normal file
31
app/Http/Requests/Common/Dashboard.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class Dashboard extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 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 [
|
||||
'name' => 'required|string',
|
||||
//'enabled' => 'integer|boolean',
|
||||
];
|
||||
}
|
||||
}
|
30
app/Http/Requests/Common/Import.php
Normal file
30
app/Http/Requests/Common/Import.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class Import extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 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 [
|
||||
'import' => 'required|file',
|
||||
];
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class Item extends Request
|
||||
class Item extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
@ -23,26 +23,20 @@ class Item extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
// Check if store or update
|
||||
if ($this->getMethod() == 'PATCH') {
|
||||
$id = $this->item->getAttribute('id');
|
||||
} else {
|
||||
$id = null;
|
||||
}
|
||||
$picture = 'nullable';
|
||||
|
||||
// Get company id
|
||||
$company_id = $this->request->get('company_id');
|
||||
if ($this->request->get('picture', null)) {
|
||||
$picture = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => 'required|string',
|
||||
'sku' => 'required|string|unique:items,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',
|
||||
'sale_price' => 'required',
|
||||
'purchase_price' => 'required',
|
||||
'quantity' => 'required|integer',
|
||||
'tax_id' => 'nullable|integer',
|
||||
'category_id' => 'nullable|integer',
|
||||
'enabled' => 'integer|boolean',
|
||||
'picture' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
|
||||
'picture' => $picture,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class Notification extends Request
|
||||
class Notification extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
|
28
app/Http/Requests/Common/Report.php
Normal file
28
app/Http/Requests/Common/Report.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class Report extends FormRequest
|
||||
{
|
||||
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string',
|
||||
'description' => 'required|string',
|
||||
'class' => 'required|string',
|
||||
'group' => 'required|string',
|
||||
'period' => 'required|string',
|
||||
'basis' => 'required|string',
|
||||
'chart' => 'required|string',
|
||||
'enabled' => 'integer|boolean',
|
||||
];
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class TotalItem extends Request
|
||||
class TotalItem extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
@ -24,19 +24,19 @@ class TotalItem extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'item.*.quantity' => 'required',
|
||||
'item.*.price' => 'required|amount',
|
||||
'item.*.currency' => 'required|string|currency',
|
||||
'items.*.quantity' => 'required',
|
||||
'items.*.price' => 'required|amount',
|
||||
'items.*.currency' => 'required|string|currency',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'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.*.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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
28
app/Http/Requests/Common/Widget.php
Normal file
28
app/Http/Requests/Common/Widget.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Common;
|
||||
|
||||
use App\Abstracts\Http\FormRequest;
|
||||
|
||||
class Widget extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 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 [];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user