1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00
invoiceninja/app/Models/Product.php
Holger Lösken 0fbda85a59 Code Refactoring
- Removed unused uses
- Type hinting for method parameters
- Removed commented code
- Introduced comments for classes and methods
- Short array syntax
2016-07-03 16:19:22 +00:00

84 lines
1.5 KiB
PHP

<?php namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Product
*/
class Product extends EntityModel
{
use SoftDeletes;
/**
* @var array
*/
protected $dates = ['deleted_at'];
/**
* @var array
*/
protected $fillable = [
'product_key',
'notes',
'cost',
'qty',
'default_tax_rate_id',
];
/**
* @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 Product::scope()->where('product_key', '=', $key)->first();
}
/**
* @return mixed
*/
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function default_tax_rate()
{
return $this->belongsTo('App\Models\TaxRate');
}
}