renamed income/expense
This commit is contained in:
77
app/Models/Purchase/BillItem.php
Normal file
77
app/Models/Purchase/BillItem.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Purchase;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Currencies;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
|
||||
class BillItem extends Model
|
||||
{
|
||||
|
||||
use Cloneable, Currencies;
|
||||
|
||||
protected $table = 'bill_items';
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'bill_id', 'item_id', 'name', 'quantity', 'price', 'total', 'tax'];
|
||||
|
||||
/**
|
||||
* Clonable relationships.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $cloneable_relations = ['taxes'];
|
||||
|
||||
public function bill()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Purchase\Bill');
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Purchase\BillItemTax', 'bill_item_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert price to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPriceAttribute($value)
|
||||
{
|
||||
$this->attributes['price'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert total to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setTotalAttribute($value)
|
||||
{
|
||||
$this->attributes['total'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert tax to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setTaxAttribute($value)
|
||||
{
|
||||
$this->attributes['tax'] = (double) $value;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user