41 lines
894 B
PHP
41 lines
894 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Items extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'items';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'description',
|
|
'price',
|
|
'image_url', // Tambahkan ini
|
|
'is_available',
|
|
'type_item_id',
|
|
'bundle_id',
|
|
];
|
|
|
|
/**
|
|
* Relasi Many-to-One: Item ini milik satu TypeItem.
|
|
*/
|
|
public function typeItem()
|
|
{
|
|
return $this->belongsTo(TypeItems::class, 'type_item_id');
|
|
}
|
|
|
|
/**
|
|
* Relasi Many-to-One: Item ini milik satu Bundle.
|
|
*/
|
|
public function items(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Items::class, 'bundle_items', 'bundle_id', 'item_id'); // Pastikan 'bundle_item'
|
|
}
|
|
}
|