39 lines
766 B
PHP
39 lines
766 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Produk extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'nama',
|
|
'id_kategori',
|
|
'berat',
|
|
'kadar',
|
|
'harga_per_gram',
|
|
'harga_jual',
|
|
];
|
|
|
|
protected $hidden = ['created_at', 'updated_at', 'deleted_at'];
|
|
|
|
public function items()
|
|
{
|
|
return $this->hasMany(Item::class, 'id_produk');
|
|
}
|
|
|
|
public function foto()
|
|
{
|
|
return $this->hasMany(Foto::class, 'id_produk');
|
|
}
|
|
|
|
public function kategori()
|
|
{
|
|
return $this->belongsTo(Kategori::class, 'id_kategori');
|
|
}
|
|
}
|