mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Fixes for name validation for expense categories
This commit is contained in:
parent
5b2a43bd9a
commit
f58ba0b502
@ -12,16 +12,10 @@
|
||||
namespace App\Http\Requests\ExpenseCategory;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\ExpenseCategory\UniqueExpenseCategoryNumberRule;
|
||||
use App\Http\ValidationRules\ValidExpenseCategoryGroupSettingsRule;
|
||||
use App\Models\ExpenseCategory;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreExpenseCategoryRequest extends Request
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
@ -36,26 +30,10 @@ class StoreExpenseCategoryRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
$rules = [];
|
||||
$rules['name'] = 'unique:expense_categories,name,'.$this->id.',id,company_id,'.$this->company_id;;
|
||||
|
||||
$rules['name'] = 'required|unique:expense_categories,name,null,null,company_id,'.auth()->user()->companyId();
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
// $input = $this->all();
|
||||
|
||||
|
||||
// $this->replace($input);
|
||||
}
|
||||
|
||||
// public function messages()
|
||||
// {
|
||||
// return [
|
||||
// 'unique' => ctrans('validation.unique', ['attribute' => 'email']),
|
||||
// //'required' => trans('validation.required', ['attribute' => 'email']),
|
||||
// 'contacts.*.email.required' => ctrans('validation.email', ['attribute' => 'email']),
|
||||
// ];
|
||||
// }
|
||||
}
|
||||
|
@ -12,15 +12,9 @@
|
||||
namespace App\Http\Requests\ExpenseCategory;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\IsDeletedRule;
|
||||
use App\Utils\Traits\ChecksEntityStatus;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateExpenseCategoryRequest extends Request
|
||||
{
|
||||
use MakesHash;
|
||||
use ChecksEntityStatus;
|
||||
|
||||
/**
|
||||
@ -35,30 +29,13 @@ class UpdateExpenseCategoryRequest extends Request
|
||||
|
||||
public function rules()
|
||||
{
|
||||
/* Ensure we have a client name, and that all emails are unique*/
|
||||
|
||||
$rules = [];
|
||||
|
||||
if ($this->input('number')) {
|
||||
$rules['name'] = 'unique:expense_categories,name,'.$this->id.',id,company_id,'.$this->expense_category->name;
|
||||
}
|
||||
if ($this->input('name'))
|
||||
$rules['name'] = 'unique:expense_categories,name,'.$this->id.',id,company_id,'.$this->expense_category->company_id;
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
// public function messages()
|
||||
// {
|
||||
// return [
|
||||
// 'unique' => ctrans('validation.unique', ['attribute' => 'email']),
|
||||
// 'email' => ctrans('validation.email', ['attribute' => 'email']),
|
||||
// 'name.required' => ctrans('validation.required', ['attribute' => 'name']),
|
||||
// 'required' => ctrans('validation.required', ['attribute' => 'email']),
|
||||
// ];
|
||||
// }
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user