akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -27,7 +27,7 @@ class Item extends Model
*
* @var array
*/
protected $fillable = ['company_id', 'name', 'description', 'sale_price', 'purchase_price', 'category_id', 'enabled', 'created_from', 'created_by'];
protected $fillable = ['company_id', 'type', 'name', 'description', 'sale_price', 'purchase_price', 'category_id', 'enabled', 'created_from', 'created_by'];
/**
* The attributes that should be cast.
@ -45,7 +45,7 @@ class Item extends Model
*
* @var array
*/
protected $sortable = ['name', 'category', 'sale_price', 'purchase_price', 'enabled'];
protected $sortable = ['name', 'category.name', 'sale_price', 'purchase_price', 'enabled'];
/**
* @var array
@ -82,6 +82,11 @@ class Item extends Model
return $query->where('name', '=', $name);
}
public function scopeBilling($query, $billing)
{
return $query->where($billing . '_price', '=', null);
}
/**
* Get the item id.
*
@ -149,6 +154,40 @@ class Item extends Model
return $this->getMedia('picture')->last();
}
/**
* Get the line actions.
*
* @return array
*/
public function getLineActionsAttribute()
{
$actions = [];
$actions[] = [
'title' => trans('general.edit'),
'icon' => 'edit',
'url' => route('items.edit', $this->id),
'permission' => 'update-common-items',
];
$actions[] = [
'title' => trans('general.duplicate'),
'icon' => 'file_copy',
'url' => route('items.duplicate', $this->id),
'permission' => 'create-common-items',
];
$actions[] = [
'type' => 'delete',
'icon' => 'delete',
'route' => 'items.destroy',
'permission' => 'delete-common-items',
'model' => $this,
];
return $actions;
}
/**
* Create a new factory instance for the model.
*