first commit

This commit is contained in:
denisdulici
2017-09-14 22:21:00 +03:00
commit 515bdaf5cd
598 changed files with 48030 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class Permission 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',
'display_name' => 'required|string',
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class Role 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',
'display_name' => 'required|string',
'permissions' => 'required'
];
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class User 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()
{
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->user->getAttribute('id');
$required = '';
} else {
$id = null;
$required = 'required|';
}
return [
'name' => 'required|string',
'email' => 'required|email|unique:users,email,' . $id . ',id,deleted_at,NULL',
'password' => $required . 'confirmed',
'roles' => 'required',
'picture' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
];
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\Banking;
use App\Http\Requests\Request;
class Account 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 [
'name' => 'required|string',
'number' => 'required|string',
'currency_code' => 'required|string',
'opening_balance' => 'required',
];
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Requests\Banking;
use App\Http\Requests\Request;
class Transfer 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 [
'from_account_id' => 'required|integer',
'to_account_id' => 'required|integer',
'amount' => 'required',
'transferred_at' => 'required|date',
'payment_method' => 'required|string',
];
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Requests\Company;
use Illuminate\Foundation\Http\FormRequest;
class Company 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 [
'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',
];
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests\Expense;
use App\Http\Requests\Request;
class Bill 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()
{
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->bill->getAttribute('id');
} else {
$id = null;
}
// Get company id
$company_id = $this->request->get('company_id');
return [
'vendor_id' => 'required|integer',
'bill_number' => 'required|string|unique:bills,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',
'billed_at' => 'required|date',
'due_at' => 'required|date',
'currency_code' => 'required|string',
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
];
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests\Expense;
use App\Http\Requests\Request;
class BillPayment 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',
'amount' => 'required',
'currency_code' => 'required|string',
'payment_method' => 'required|string',
'attachment' => 'mimes:' . setting('general.file_types', 'pdf,jpeg,jpg,png'),
];
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Http\Requests\Expense;
use App\Http\Requests\Request;
class Payment 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',
'amount' => 'required',
'currency_code' => 'required|string',
'category_id' => 'required|integer',
'payment_method' => 'required|string',
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
];
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace App\Http\Requests\Expense;
use App\Http\Requests\Request;
class Vendor 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()
{
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->vendor->getAttribute('id');
} else {
$id = null;
}
// Get company id
$company_id = $this->request->get('company_id');
return [
'name' => 'required|string',
'email' => 'required|email|unique:vendors,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',
'currency_code' => 'required|string',
];
}
}

View File

@ -0,0 +1,49 @@
<?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()
{
$required = '';
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->customer->getAttribute('id');
} else {
$id = null;
}
if (!empty($this->request->get('create_user'))) {
$required = 'required|';
}
// Get company id
$company_id = $this->request->get('company_id');
return [
'name' => 'required|string',
'email' => 'required|email|unique:customers,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',
'currency_code' => 'required|string',
'password' => $required . 'confirmed',
];
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests\Income;
use App\Http\Requests\Request;
class Invoice 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()
{
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->invoice->getAttribute('id');
} else {
$id = null;
}
// Get company id
$company_id = $this->request->get('company_id');
return [
'customer_id' => 'required|integer',
'invoice_number' => 'required|string|unique:invoices,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',
'invoiced_at' => 'required|date',
'due_at' => 'required|date',
'currency_code' => 'required|string',
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
];
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests\Income;
use App\Http\Requests\Request;
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',
'amount' => 'required',
'currency_code' => 'required|string',
'payment_method' => 'required|string',
'attachment' => 'mimes:jpeg,jpg,png,pdf',
];
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Http\Requests\Income;
use App\Http\Requests\Request;
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',
'amount' => 'required',
'currency_code' => 'required|string',
'category_id' => 'required|integer',
'payment_method' => 'required|string',
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Install;
use App\Http\Requests\Request;
class Database 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 [
'hostname' => 'required',
'username' => 'required',
'database' => 'required'
];
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\Install;
use App\Http\Requests\Request;
class Setting 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 [
'company_name' => 'required',
'company_email' => 'required',
'user_email' => 'required',
'user_password' => 'required'
];
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests\Item;
use App\Http\Requests\Request;
class Item 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()
{
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->item->getAttribute('id');
} else {
$id = null;
}
// Get company id
$company_id = $this->request->get('company_id');
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',
'picture' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
];
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Module;
use App\Http\Requests\Request;
class Module 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 [
'api_token' => 'required|string',
];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class Request extends FormRequest
{
/**
* Set the company id to the request.
*
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function getValidatorInstance()
{
// Get request data
$data = $this->all();
// Add active company id
$data['company_id'] = session('company_id');
// Reset the request data
$this->getInputSource()->replace($data);
return parent::getValidatorInstance();
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Setting;
use App\Http\Requests\Request;
class Category 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 [
'name' => 'required|string',
'type' => 'required|string',
'color' => 'required|string',
];
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace App\Http\Requests\Setting;
use App\Http\Requests\Request;
class Currency 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()
{
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->currency->getAttribute('id');
} else {
$id = null;
}
// Get company id
$company_id = $this->request->get('company_id');
return [
'name' => 'required|string',
'code' => 'required|string|unique:currencies,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',
'rate' => 'required',
'enabled' => 'boolean',
'default_currency' => 'boolean',
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Setting;
use App\Http\Requests\Request;
class Setting 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 [
'company_name' => 'required|string',
'company_email' => 'required|email',
'company_logo' => 'mimes:' . setting('general.file_types', 'pdf,jpeg,jpg,png'),
];
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Setting;
use App\Http\Requests\Request;
class Tax 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 [
'name' => 'required|string',
'rate' => 'required',
];
}
}