Clean up error logs from API
This commit is contained in:
parent
e4a7f4c614
commit
763c5e08a5
16 changed files with 39 additions and 15 deletions
|
|
@ -121,6 +121,10 @@ class BaseAPIController extends Controller
|
|||
|
||||
protected function itemResponse($item)
|
||||
{
|
||||
if (! $item) {
|
||||
return $this->errorResponse('Record not found', 404);
|
||||
}
|
||||
|
||||
$transformerClass = EntityModel::getTransformerName($this->entityType);
|
||||
$transformer = new $transformerClass(Auth::user()->account, Input::get('serializer'));
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateClientRequest extends ClientRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -21,6 +21,10 @@ class UpdateClientRequest extends ClientRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
if (! $this->entity()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rules = [];
|
||||
|
||||
if ($this->user()->account->client_number_counter) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateContactRequest extends ContactRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateCreditRequest extends CreditRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateDocumentRequest extends DocumentRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateExpenseCategoryRequest extends ExpenseCategoryRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -21,6 +21,10 @@ class UpdateExpenseCategoryRequest extends ExpenseCategoryRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
if (! $this->entity()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => 'required',
|
||||
'name' => sprintf('required|unique:expense_categories,name,%s,id,account_id,%s', $this->entity()->id, $this->user()->account_id),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateExpenseRequest extends ExpenseRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class UpdateInvoiceAPIRequest extends InvoiceRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -23,6 +23,10 @@ class UpdateInvoiceAPIRequest extends InvoiceRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
if (! $this->entity()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($this->action == ACTION_ARCHIVE) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class UpdateInvoiceRequest extends InvoiceRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -23,6 +23,10 @@ class UpdateInvoiceRequest extends InvoiceRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
if (! $this->entity()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$invoiceId = $this->entity()->id;
|
||||
|
||||
$rules = [
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdatePaymentRequest extends PaymentRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateProductRequest extends ProductRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateProjectRequest extends ProjectRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -21,6 +21,10 @@ class UpdateProjectRequest extends ProjectRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
if (! $this->entity()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => sprintf('required|unique:projects,name,%s,id,account_id,%s', $this->entity()->id, $this->user()->account_id),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateRecurringExpenseRequest extends RecurringExpenseRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateTaskRequest extends TaskRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateTaxRateRequest extends TaxRateRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class UpdateVendorRequest extends VendorRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->entity());
|
||||
return $this->entity() && $this->user()->can('edit', $this->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue