mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
v6 update
This commit is contained in:
40
app/Http/Requests/AvatarRequest.php
Normal file
40
app/Http/Requests/AvatarRequest.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Requests;
|
||||
|
||||
use Crater\Rules\Base64Mime;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AvatarRequest 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 [
|
||||
'admin_avatar' => [
|
||||
'nullable',
|
||||
'file',
|
||||
'mimes:gif,jpg,png',
|
||||
'max:20000'
|
||||
],
|
||||
'avatar' => [
|
||||
'nullable',
|
||||
new Base64Mime(['gif', 'jpg', 'png'])
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@
|
||||
namespace Crater\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CompaniesRequest extends FormRequest
|
||||
@ -70,7 +71,8 @@ class CompaniesRequest extends FormRequest
|
||||
'name'
|
||||
])
|
||||
->merge([
|
||||
'owner_id' => $this->user()->id
|
||||
'owner_id' => $this->user()->id,
|
||||
'slug' => Str::slug($this->name)
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
34
app/Http/Requests/CompanyLogoRequest.php
Normal file
34
app/Http/Requests/CompanyLogoRequest.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Requests;
|
||||
|
||||
use Crater\Rules\Base64Mime;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CompanyLogoRequest 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 [
|
||||
'company_logo' => [
|
||||
'nullable',
|
||||
new Base64Mime(['gif', 'jpg', 'png'])
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -29,9 +29,22 @@ class CompanyRequest extends FormRequest
|
||||
'required',
|
||||
Rule::unique('companies')->ignore($this->header('company'), 'id'),
|
||||
],
|
||||
'slug' => [
|
||||
'nullable'
|
||||
],
|
||||
'address.country_id' => [
|
||||
'required',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getCompanyPayload()
|
||||
{
|
||||
return collect($this->validated())
|
||||
->only([
|
||||
'name',
|
||||
'slug'
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
37
app/Http/Requests/Customer/CustomerLoginRequest.php
Normal file
37
app/Http/Requests/Customer/CustomerLoginRequest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Requests\Customer;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CustomerLoginRequest 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 [
|
||||
'email' => [
|
||||
'required',
|
||||
'string'
|
||||
],
|
||||
'password' => [
|
||||
'required',
|
||||
'string'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
116
app/Http/Requests/Customer/CustomerProfileRequest.php
Normal file
116
app/Http/Requests/Customer/CustomerProfileRequest.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Requests\Customer;
|
||||
|
||||
use Crater\Models\Address;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CustomerProfileRequest 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' => [
|
||||
'nullable',
|
||||
],
|
||||
'password' => [
|
||||
'nullable',
|
||||
'min:8',
|
||||
],
|
||||
'email' => [
|
||||
'nullable',
|
||||
'email',
|
||||
Rule::unique('customers')->where('company_id', $this->header('company'))->ignore(Auth::id(), 'id'),
|
||||
],
|
||||
'billing.name' => [
|
||||
'nullable',
|
||||
],
|
||||
'billing.address_street_1' => [
|
||||
'nullable',
|
||||
],
|
||||
'billing.address_street_2' => [
|
||||
'nullable',
|
||||
],
|
||||
'billing.city' => [
|
||||
'nullable',
|
||||
],
|
||||
'billing.state' => [
|
||||
'nullable',
|
||||
],
|
||||
'billing.country_id' => [
|
||||
'nullable',
|
||||
],
|
||||
'billing.zip' => [
|
||||
'nullable',
|
||||
],
|
||||
'billing.phone' => [
|
||||
'nullable',
|
||||
],
|
||||
'billing.fax' => [
|
||||
'nullable',
|
||||
],
|
||||
'shipping.name' => [
|
||||
'nullable',
|
||||
],
|
||||
'shipping.address_street_1' => [
|
||||
'nullable',
|
||||
],
|
||||
'shipping.address_street_2' => [
|
||||
'nullable',
|
||||
],
|
||||
'shipping.city' => [
|
||||
'nullable',
|
||||
],
|
||||
'shipping.state' => [
|
||||
'nullable',
|
||||
],
|
||||
'shipping.country_id' => [
|
||||
'nullable',
|
||||
],
|
||||
'shipping.zip' => [
|
||||
'nullable',
|
||||
],
|
||||
'shipping.phone' => [
|
||||
'nullable',
|
||||
],
|
||||
'shipping.fax' => [
|
||||
'nullable',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function getShippingAddress()
|
||||
{
|
||||
return collect($this->shipping)
|
||||
->merge([
|
||||
'type' => Address::SHIPPING_TYPE
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function getBillingAddress()
|
||||
{
|
||||
return collect($this->billing)
|
||||
->merge([
|
||||
'type' => Address::BILLING_TYPE
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/CustomerEstimateStatusRequest.php
Normal file
33
app/Http/Requests/CustomerEstimateStatusRequest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CustomerEstimateStatusRequest 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 [
|
||||
'status' => [
|
||||
'required',
|
||||
'in:ACCEPTED,REJECTED',
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,8 @@ class CustomerRequest extends FormRequest
|
||||
'nullable',
|
||||
],
|
||||
'enable_portal' => [
|
||||
'nullable',
|
||||
|
||||
'boolean'
|
||||
],
|
||||
'currency_id' => [
|
||||
'nullable',
|
||||
@ -119,7 +120,7 @@ class CustomerRequest extends FormRequest
|
||||
$rules['email'] = [
|
||||
'email',
|
||||
'nullable',
|
||||
Rule::unique('customers')->ignore($this->route('customer')->id),
|
||||
Rule::unique('customers')->where('company_id', $this->header('company'))->ignore($this->route('customer')->id),
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
@ -51,6 +51,12 @@ class ExpenseRequest extends FormRequest
|
||||
'currency_id' => [
|
||||
'required'
|
||||
],
|
||||
'attachment_receipt' => [
|
||||
'nullable',
|
||||
'file',
|
||||
'mimes:jpg,png,pdf,doc,docx,xls,xlsx,ppt,pptx',
|
||||
'max:20000'
|
||||
]
|
||||
];
|
||||
|
||||
if ($companyCurrency && $this->currency_id) {
|
||||
|
||||
33
app/Http/Requests/GetSettingRequest.php
Normal file
33
app/Http/Requests/GetSettingRequest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class GetSettingRequest 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 [
|
||||
'key' => [
|
||||
'required',
|
||||
'string'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Crater\Http\Requests;
|
||||
|
||||
use Crater\Models\PaymentMethod;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@ -43,4 +44,14 @@ class PaymentMethodRequest extends FormRequest
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getPaymentMethodPayload()
|
||||
{
|
||||
return collect($this->validated())
|
||||
->merge([
|
||||
'company_id' => $this->header('company'),
|
||||
'type' => PaymentMethod::TYPE_GENERAL,
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,10 +24,7 @@ class SettingRequest extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'key' => [
|
||||
'required',
|
||||
],
|
||||
'value' => [
|
||||
'settings' => [
|
||||
'required',
|
||||
],
|
||||
];
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Crater\Http\Requests;
|
||||
|
||||
use Crater\Models\TaxType;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@ -28,6 +29,7 @@ class TaxTypeRequest extends FormRequest
|
||||
'name' => [
|
||||
'required',
|
||||
Rule::unique('tax_types')
|
||||
->where('type', TaxType::TYPE_GENERAL)
|
||||
->where('company_id', $this->header('company'))
|
||||
],
|
||||
'percent' => [
|
||||
@ -49,6 +51,7 @@ class TaxTypeRequest extends FormRequest
|
||||
'required',
|
||||
Rule::unique('tax_types')
|
||||
->ignore($this->route('tax_type')->id)
|
||||
->where('type', TaxType::TYPE_GENERAL)
|
||||
->where('company_id', $this->header('company'))
|
||||
];
|
||||
}
|
||||
@ -60,7 +63,8 @@ class TaxTypeRequest extends FormRequest
|
||||
{
|
||||
return collect($this->validated())
|
||||
->merge([
|
||||
'company_id' => $this->header('company')
|
||||
'company_id' => $this->header('company'),
|
||||
'type' => TaxType::TYPE_GENERAL
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user