1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Move from guarded models to fillable properties.. overcomes handling additional response parameters

This commit is contained in:
David Bomba 2019-06-26 14:04:10 +10:00
parent 879d87ea60
commit f01c038c6e
11 changed files with 167 additions and 22 deletions

View File

@ -39,7 +39,7 @@ class Client extends BaseModel
protected $appends = [ protected $appends = [
]; ];
/*
protected $guarded = [ protected $guarded = [
'id', 'id',
'updated_at', 'updated_at',
@ -52,6 +52,37 @@ class Client extends BaseModel
'country', 'country',
'shipping_country' 'shipping_country'
]; ];
*/
protected $fillable = [
'name',
'website',
'private_notes',
'industry_id',
'size_id',
'currency_id',
'address1',
'address2',
'city',
'state',
'postal_code',
'country_id',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4,',
'shipping_address1',
'shipping_address2',
'shipping_city',
'shipping_state',
'shipping_postal_code',
'shipping_country_id',
'settings',
'payment_terms',
'vat_number',
'id_number',
];
/* /*
protected $with = [ protected $with = [
'contacts', 'contacts',

View File

@ -35,8 +35,16 @@ class ClientContact extends Authenticatable
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];
protected $guarded = [ protected $fillable = [
'id', 'first_name',
'last_name',
'phone',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4',
'email',
'avatar',
]; ];
protected $hidden = [ protected $hidden = [

View File

@ -44,6 +44,20 @@ class Company extends BaseModel
protected $fillable = [ protected $fillable = [
'name', 'name',
'logo', 'logo',
'industry_id',
'address1',
'address2',
'city',
'state',
'postal_code',
'work_phone',
'work_email',
'country_id',
'subdomain',
'vat_number',
'id_number',
'size_id',
'settings',
]; ];
protected $appends = [ protected $appends = [

View File

@ -48,6 +48,8 @@ class Invoice extends BaseModel
'partial_due_date', 'partial_due_date',
'custom_value1', 'custom_value1',
'custom_value2', 'custom_value2',
'custom_value3',
'custom_value4',
'custom_taxes1', 'custom_taxes1',
'custom_taxes2', 'custom_taxes2',
'custom_text_value1', 'custom_text_value1',
@ -55,6 +57,7 @@ class Invoice extends BaseModel
'line_items', 'line_items',
'settings', 'settings',
'client_id', 'client_id',
'footer',
]; ];
protected $casts = [ protected $casts = [

View File

@ -27,8 +27,12 @@ class Payment extends BaseModel
const STATUS_PARTIALLY_REFUNDED = 5; const STATUS_PARTIALLY_REFUNDED = 5;
const STATUS_REFUNDED = 6; const STATUS_REFUNDED = 6;
protected $guarded = [ protected $fillable = [
'id', 'client_id',
'payment_type_id',
'amount',
'payment_date',
'transaction_reference'
]; ];
public function client() public function client()

View File

@ -22,12 +22,20 @@ class Product extends BaseModel
use SoftDeletes; use SoftDeletes;
use Filterable; use Filterable;
protected $guarded = [ protected $fillable = [
'id', 'custom_value1',
'updated_at', 'custom_value2',
'created_at', 'custom_value3',
'deleted_at', 'custom_value4',
'q', 'product_key',
'notes',
'cost',
'price',
'qty',
'tax_name1',
'tax_name2',
'tax_rate1',
'tax_rate2',
]; ];
public function company() public function company()

View File

@ -20,8 +20,31 @@ class Quote extends BaseModel
use MakesHash; use MakesHash;
use Filterable; use Filterable;
protected $guarded = [ protected $fillable = [
'id', 'client_id',
'quote_number',
'discount',
'is_amount_discount',
'po_number',
'quote_date',
'valid_until',
'line_items',
'settings',
'footer',
'public_note',
'private_notes',
'terms',
'tax_name1',
'tax_name2',
'tax_rate1',
'tax_rate2',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4',
'amount',
'partial',
'partial_due_date',
]; ];
protected $casts = [ protected $casts = [

View File

@ -52,8 +52,32 @@ class RecurringInvoice extends BaseModel
const RECURS_INDEFINITELY = -1; const RECURS_INDEFINITELY = -1;
protected $guarded = [ protected $fillable = [
'id', 'client_id',
'invoice_number',
'discount'
'is_amount_discount',
'po_number',
'invoice_date',
'due_date',
'line_items',
'settings',
'footer',
'public_notes'
'private_notes',
'terms',
'tax_name1',
'tax_name2',
'tax_rate1',
'tax_rate2',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4',
'amount',
'partial'
'frequency_id'
'start_date',
]; ];
protected $casts = [ protected $casts = [

View File

@ -51,9 +51,32 @@ class RecurringQuote extends BaseModel
const RECURS_INDEFINITELY = -1; const RECURS_INDEFINITELY = -1;
protected $guarded = [ protected $fillable = [
'id', 'client_id',
]; 'quote_number',
'discount',
'is_amount_discount',
'po_number',
'quote_date',
'valid_until',
'line_items',
'settings',
'footer',
'public_note',
'private_notes',
'terms',
'tax_name1',
'tax_name2',
'tax_rate1',
'tax_rate2',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4',
'amount',
'frequency_id',
'start_date',
];
protected $casts = [ protected $casts = [
'settings' => 'object' 'settings' => 'object'

View File

@ -18,8 +18,14 @@ class Task extends BaseModel
{ {
use MakesHash; use MakesHash;
protected $guarded = [ protected $fillable = [
'id', 'client_id',
'invoice_id',
'custom_value1',
'custom_value2',
'description',
'is_running',
'time_log',
]; ];
protected $appends = ['task_id']; protected $appends = ['task_id'];

View File

@ -18,8 +18,9 @@ class TaxRate extends BaseModel
{ {
use MakesHash; use MakesHash;
protected $guarded = [ protected $fillable = [
'id', 'name',
'rate'
]; ];
protected $appends = ['tax_rate_id']; protected $appends = ['tax_rate_id'];