Files
star-cloud/app/Models/Product/Product.php

60 lines
1.3 KiB
PHP

<?php
namespace App\Models\Product;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Traits\TenantScoped;
class Product extends Model
{
use HasFactory, SoftDeletes, TenantScoped;
protected $fillable = [
'company_id',
'category_id',
'name',
'name_dictionary_key',
'sku',
'barcode',
'spec',
'manufacturer',
'description',
'price',
'member_price',
'cost',
'track_limit',
'spring_limit',
'type',
'image_url',
'status',
'is_active',
'metadata',
];
protected $casts = [
'price' => 'decimal:2',
'member_price' => 'decimal:2',
'cost' => 'decimal:2',
'track_limit' => 'integer',
'spring_limit' => 'integer',
'is_active' => 'boolean',
'metadata' => 'array',
];
public function category()
{
return $this->belongsTo(ProductCategory::class, 'category_id');
}
/**
* Get the translations for the product name.
*/
public function translations()
{
return $this->hasMany(\App\Models\System\Translation::class, 'key', 'name_dictionary_key')
->where('group', 'product');
}
}