mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for permissions
This commit is contained in:
parent
91e23ee189
commit
909db91184
@ -225,22 +225,6 @@ class ClientExport extends BaseExport
|
||||
$entity['client.assigned_user'] = $client->assigned_user ? $client->user->present()->name() : '';
|
||||
}
|
||||
|
||||
// if (in_array('client.country_id', $this->input['report_keys'])) {
|
||||
// $entity['client.country_id'] = $client->country ? ctrans("texts.country_{$client->country->name}") : '';
|
||||
// }
|
||||
|
||||
// if (in_array('client.shipping_country_id', $this->input['report_keys'])) {
|
||||
// $entity['client.shipping_country_id'] = $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : '';
|
||||
// }
|
||||
|
||||
// if (in_array('client.currency_id', $this->input['report_keys'])) {
|
||||
// $entity['client.currency_id'] = $client->currency() ? $client->currency()->code : $client->company->currency()->code;
|
||||
// }
|
||||
|
||||
// if (in_array('client.industry_id', $this->input['report_keys'])) {
|
||||
// $entity['industry_id'] = $client->industry ? ctrans("texts.industry_{$client->industry->name}") : '';
|
||||
// }
|
||||
|
||||
if (in_array('client.classification', $this->input['report_keys']) && isset($client->classification)) {
|
||||
$entity['client.classification'] = ctrans("texts.{$client->classification}") ?? '';
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class StoreClientRequest extends Request
|
||||
|
||||
$rules['number'] = ['bail', 'nullable', Rule::unique('clients')->where('company_id', $user->company()->id)];
|
||||
$rules['id_number'] = ['bail', 'nullable', Rule::unique('clients')->where('company_id', $user->company()->id)];
|
||||
$rules['classification'] = 'bail|sometimes|nullable|in:individual,business,partnership,trust,charity,government,other';
|
||||
$rules['classification'] = 'bail|sometimes|nullable|in:individual,business,company,partnership,trust,charity,government,other';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class UpdateClientRequest extends Request
|
||||
$rules['size_id'] = 'integer|nullable';
|
||||
$rules['country_id'] = 'integer|nullable';
|
||||
$rules['shipping_country_id'] = 'integer|nullable';
|
||||
$rules['classification'] = 'bail|sometimes|nullable|in:individual,business,partnership,trust,charity,government,other';
|
||||
$rules['classification'] = 'bail|sometimes|nullable|in:individual,business,company,partnership,trust,charity,government,other';
|
||||
|
||||
if ($this->id_number) {
|
||||
$rules['id_number'] = Rule::unique('clients')->where('company_id', $user->company()->id)->ignore($this->client->id);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Http\Requests\ExpenseCategory;
|
||||
|
||||
use App\Models\Expense;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\ExpenseCategory;
|
||||
|
||||
@ -23,14 +24,21 @@ class StoreExpenseCategoryRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->user()->can('create', ExpenseCategory::class);
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->can('create', ExpenseCategory::class) || $user->can('create', Expense::class);
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$rules = [];
|
||||
|
||||
$rules['name'] = 'required|unique:expense_categories,name,null,null,company_id,'.auth()->user()->companyId();
|
||||
$rules['name'] = 'required|unique:expense_categories,name,null,null,company_id,'.$user->companyId();
|
||||
|
||||
return $this->globalRules($rules);
|
||||
}
|
||||
|
@ -26,16 +26,24 @@ class UpdateExpenseCategoryRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->user()->can('edit', $this->expense_category);
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->can('edit', $this->expense_category);
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$rules = [];
|
||||
|
||||
if ($this->input('name')) {
|
||||
// $rules['name'] = 'unique:expense_categories,name,'.$this->id.',id,company_id,'.$this->expense_category->company_id;
|
||||
$rules['name'] = Rule::unique('expense_categories')->where('company_id', auth()->user()->company()->id)->ignore($this->expense_category->id);
|
||||
$rules['name'] = Rule::unique('expense_categories')->where('company_id', $user->company()->id)->ignore($this->expense_category->id);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
|
@ -73,7 +73,7 @@ class StoreVendorRequest extends Request
|
||||
}
|
||||
|
||||
$rules['language_id'] = 'bail|nullable|sometimes|exists:languages,id';
|
||||
$rules['classification'] = 'bail|sometimes|nullable|in:individual,company,partnership,trust,charity,government,other';
|
||||
$rules['classification'] = 'bail|sometimes|nullable|in:individual,business,company,partnership,trust,charity,government,other';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class UpdateVendorRequest extends Request
|
||||
}
|
||||
|
||||
$rules['language_id'] = 'bail|nullable|sometimes|exists:languages,id';
|
||||
$rules['classification'] = 'bail|sometimes|nullable|in:individual,company,partnership,trust,charity,government,other';
|
||||
$rules['classification'] = 'bail|sometimes|nullable|in:individual,business,company,partnership,trust,charity,government,other';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
@ -5120,7 +5120,7 @@ $lang = array(
|
||||
'set_private' => 'Set private',
|
||||
'individual' => 'Individual',
|
||||
'business' => 'Business',
|
||||
'partnership' => 'partnership',
|
||||
'partnership' => 'Partnership',
|
||||
'trust' => 'Trust',
|
||||
'charity' => 'Charity',
|
||||
'government' => 'Government',
|
||||
|
Loading…
Reference in New Issue
Block a user