added attribute casting
This commit is contained in:
		@@ -29,6 +29,15 @@ class User extends Authenticatable
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['name', 'email', 'password', 'locale', 'enabled', 'landing_page'];
 | 
					    protected $fillable = ['name', 'email', 'password', 'locale', 'enabled', 'landing_page'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'enabled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The attributes that should be hidden for arrays.
 | 
					     * The attributes that should be hidden for arrays.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -43,15 +52,6 @@ class User extends Authenticatable
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $dates = ['last_logged_in_at', 'created_at', 'updated_at', 'deleted_at'];
 | 
					    protected $dates = ['last_logged_in_at', 'created_at', 'updated_at', 'deleted_at'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * The attributes that should be cast.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @var array
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    protected $casts = [
 | 
					 | 
				
			||||||
        'enabled' => 'boolean',
 | 
					 | 
				
			||||||
    ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,6 +26,16 @@ class Account extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'name', 'number', 'currency_code', 'opening_balance', 'bank_name', 'bank_phone', 'bank_address', 'enabled'];
 | 
					    protected $fillable = ['company_id', 'name', 'number', 'currency_code', 'opening_balance', 'bank_name', 'bank_phone', 'bank_address', 'enabled'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'opening_balance' => 'double',
 | 
				
			||||||
 | 
					        'enabled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -63,17 +73,6 @@ class Account extends Model
 | 
				
			|||||||
        return $query->where('number', '=', $number);
 | 
					        return $query->where('number', '=', $number);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Convert opening balance to double.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param  string  $value
 | 
					 | 
				
			||||||
     * @return void
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function setOpeningBalanceAttribute($value)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->attributes['opening_balance'] = (double) $value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Get the current balance.
 | 
					     * Get the current balance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,16 @@ class Reconciliation extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'account_id', 'started_at', 'ended_at', 'closing_balance', 'reconciled'];
 | 
					    protected $fillable = ['company_id', 'account_id', 'started_at', 'ended_at', 'closing_balance', 'reconciled'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'closing_balance' => 'double',
 | 
				
			||||||
 | 
					        'reconciled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -28,15 +38,4 @@ class Reconciliation extends Model
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        return $this->belongsTo('App\Models\Banking\Account');
 | 
					        return $this->belongsTo('App\Models\Banking\Account');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Convert closing balance to double.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param  string  $value
 | 
					 | 
				
			||||||
     * @return void
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function setClosingBalanceAttribute($value)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->attributes['closing_balance'] = (double) $value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,16 @@ class Transaction extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'type', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'document_id', 'contact_id', 'description', 'category_id', 'payment_method', 'reference', 'parent_id'];
 | 
					    protected $fillable = ['company_id', 'type', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'document_id', 'contact_id', 'description', 'category_id', 'payment_method', 'reference', 'parent_id'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'amount' => 'double',
 | 
				
			||||||
 | 
					        'currency_rate' => 'double',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -225,28 +235,6 @@ class Transaction extends Model
 | 
				
			|||||||
        $this->document_id = null;
 | 
					        $this->document_id = null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Convert amount to double.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param  string  $value
 | 
					 | 
				
			||||||
     * @return void
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function setAmountAttribute($value)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->attributes['amount'] = (double) $value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Convert currency rate to double.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param  string  $value
 | 
					 | 
				
			||||||
     * @return void
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function setCurrencyRateAttribute($value)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->attributes['currency_rate'] = (double) $value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Convert amount to double.
 | 
					     * Convert amount to double.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,15 @@ class Contact extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'type', 'name', 'email', 'user_id', 'tax_number', 'phone', 'address', 'website', 'currency_code', 'reference', 'enabled'];
 | 
					    protected $fillable = ['company_id', 'type', 'name', 'email', 'user_id', 'tax_number', 'phone', 'address', 'website', 'currency_code', 'reference', 'enabled'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'enabled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,15 @@ class Dashboard extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'name', 'enabled'];
 | 
					    protected $fillable = ['company_id', 'name', 'enabled'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'enabled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,17 @@ class Item extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'name', 'description', 'sale_price', 'purchase_price', 'category_id', 'tax_id', 'enabled'];
 | 
					    protected $fillable = ['company_id', 'name', 'description', 'sale_price', 'purchase_price', 'category_id', 'tax_id', 'enabled'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'sale_price' => 'double',
 | 
				
			||||||
 | 
					        'purchase_price' => 'double',
 | 
				
			||||||
 | 
					        'enabled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -60,28 +71,6 @@ class Item extends Model
 | 
				
			|||||||
        return $query->where('name', '=', $name);
 | 
					        return $query->where('name', '=', $name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Convert sale price to double.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param  string  $value
 | 
					 | 
				
			||||||
     * @return void
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function setSalePriceAttribute($value)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->attributes['sale_price'] = (double) $value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Convert purchase price to double.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param  string  $value
 | 
					 | 
				
			||||||
     * @return void
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function setPurchasePriceAttribute($value)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->attributes['purchase_price'] = (double) $value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Get the item id.
 | 
					     * Get the item id.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,7 @@ class Report extends Model
 | 
				
			|||||||
    protected $fillable = ['company_id', 'class', 'name', 'description', 'settings'];
 | 
					    protected $fillable = ['company_id', 'class', 'name', 'description', 'settings'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The attributes that should be casted to native types.
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @var array
 | 
					     * @var array
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,7 @@ class Widget extends Model
 | 
				
			|||||||
    protected $fillable = ['company_id', 'dashboard_id', 'class', 'name', 'sort', 'settings'];
 | 
					    protected $fillable = ['company_id', 'dashboard_id', 'class', 'name', 'sort', 'settings'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The attributes that should be casted to native types.
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @var array
 | 
					     * @var array
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,15 @@ class Module extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'alias', 'enabled'];
 | 
					    protected $fillable = ['company_id', 'alias', 'enabled'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'enabled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Scope alias.
 | 
					     * Scope alias.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,15 @@ class Category extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'name', 'type', 'color', 'enabled'];
 | 
					    protected $fillable = ['company_id', 'name', 'type', 'color', 'enabled'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'enabled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,16 @@ class Currency extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'name', 'code', 'rate', 'enabled', 'precision', 'symbol', 'symbol_first', 'decimal_mark', 'thousands_separator'];
 | 
					    protected $fillable = ['company_id', 'name', 'code', 'rate', 'enabled', 'precision', 'symbol', 'symbol_first', 'decimal_mark', 'thousands_separator'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'rate' => 'double',
 | 
				
			||||||
 | 
					        'enabled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -72,17 +82,6 @@ class Currency extends Model
 | 
				
			|||||||
        return $this->contacts()->whereIn('type', (array) $this->getVendorTypes());
 | 
					        return $this->contacts()->whereIn('type', (array) $this->getVendorTypes());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Convert rate to double.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param  string  $value
 | 
					 | 
				
			||||||
     * @return void
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function setRateAttribute($value)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->attributes['rate'] = (double) $value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Get the current precision.
 | 
					     * Get the current precision.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,16 @@ class Tax extends Model
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $fillable = ['company_id', 'name', 'rate', 'type', 'enabled'];
 | 
					    protected $fillable = ['company_id', 'name', 'rate', 'type', 'enabled'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The attributes that should be cast.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected $casts = [
 | 
				
			||||||
 | 
					        'rate' => 'double',
 | 
				
			||||||
 | 
					        'enabled' => 'boolean',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sortable columns.
 | 
					     * Sortable columns.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -101,17 +111,6 @@ class Tax extends Model
 | 
				
			|||||||
        return $query->where($this->table . '.type', '<>', 'withholding');
 | 
					        return $query->where($this->table . '.type', '<>', 'withholding');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Convert rate to double.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param  string  $value
 | 
					 | 
				
			||||||
     * @return void
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function setRateAttribute($value)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->attributes['rate'] = (double) $value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Get the name including rate.
 | 
					     * Get the name including rate.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user