mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
91 lines
1.6 KiB
PHP
91 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Laracasts\Presenter\PresentableTrait;
|
|
|
|
/**
|
|
* Class Product.
|
|
*/
|
|
class Product extends EntityModel
|
|
{
|
|
use PresentableTrait;
|
|
use SoftDeletes;
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $dates = ['deleted_at'];
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $presenter = 'App\Ninja\Presenters\ProductPresenter';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'product_key',
|
|
'notes',
|
|
'cost',
|
|
'qty',
|
|
'tax_name1',
|
|
'tax_rate1',
|
|
'tax_name2',
|
|
'tax_rate2',
|
|
'custom_value1',
|
|
'custom_value2',
|
|
];
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function getImportColumns()
|
|
{
|
|
return [
|
|
'product_key',
|
|
'notes',
|
|
'cost',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function getImportMap()
|
|
{
|
|
return [
|
|
'product|item' => 'product_key',
|
|
'notes|description|details' => 'notes',
|
|
'cost|amount|price' => 'cost',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getEntityType()
|
|
{
|
|
return ENTITY_PRODUCT;
|
|
}
|
|
|
|
/**
|
|
* @param $key
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function findProductByKey($key)
|
|
{
|
|
return self::scope()->where('product_key', '=', $key)->first();
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('App\Models\User')->withTrashed();
|
|
}
|
|
}
|