F
Filament6mo ago
Rojak

Decrement Product quantity after created Order with Repeater

I have 3 model: Barang (Product), TransaksiKeluar (Order), and TransaksiKeluarItem (OrderItem) Inside Order resource there is repeater for OrderItem. My goal is when an order created, product quantity will decrease based on product and qty in repeater. Also if possible retain previous record so if an order got deleted or edited it will back to previous record. Here my models and relationship Barang Model (Product)
public function transaksi_keluar_item(): HasMany
{
return $this->hasMany(TransaksiKeluarItem::class);
}
public function transaksi_keluar_item(): HasMany
{
return $this->hasMany(TransaksiKeluarItem::class);
}
TransaksiKeluar Model (Order)
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function transaksi_keluar_item(): HasMany
{
return $this->hasMany(TransaksiKeluarItem::class);
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function transaksi_keluar_item(): HasMany
{
return $this->hasMany(TransaksiKeluarItem::class);
}
TransaksiKeluarItem (OrderItem)
public function transaksi_keluar(): BelongsTo
{
return $this->belongsTo(TransaksiKeluar::class);
}

public function barang(): BelongsTo
{
return $this->belongsTo(Barang::class);
}
public function transaksi_keluar(): BelongsTo
{
return $this->belongsTo(TransaksiKeluar::class);
}

public function barang(): BelongsTo
{
return $this->belongsTo(Barang::class);
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server