Rojak
Rojak
FFilament
Created by Rojak on 12/22/2024 in #❓┊help
filters with relation date
iam using custom page for my report page, then i add date range filter on report page using relation data "tgl_penjualan" from other table. It work fine on Columns and DefaultSort but always error on Filters. At first it says column not found everytime i pick date, then after some tinkering it doesnt show any error when pick date but the data on table stay the same not filtered. Below is my current table code "LaporanJual.php" in App/Filament/Pages
public static function table(Table $table): Table
{return $table
->query(TransaksiKeluarItem::query()
->join('transaksi_keluars', 'transaksi_keluar_items.transaksi_keluar_id', '=', 'transaksi_keluars.id')
->select(
'transaksi_keluars.tgl_penjualan as Tanggal',
'transaksi_keluar_items.id as item_id',
'transaksi_keluar_items.*'
)
)
->columns([...])
->defaultSort('Tanggal', 'desc')
->filters([
DateRangeFilter::make('Tanggal')
->query(function ($query) {
$filter = request()->all();
if (isset($filter['start']) && isset($filter['end'])) {
$startDate = Carbon::parse($filter['start']);
$endDate = Carbon::parse($filter['end'])->endOfDay();

$query->whereBetween('transaksi_keluars.tgl_penjualan', [
$startDate,
$endDate,
]);
}
}),
]);
}
public static function table(Table $table): Table
{return $table
->query(TransaksiKeluarItem::query()
->join('transaksi_keluars', 'transaksi_keluar_items.transaksi_keluar_id', '=', 'transaksi_keluars.id')
->select(
'transaksi_keluars.tgl_penjualan as Tanggal',
'transaksi_keluar_items.id as item_id',
'transaksi_keluar_items.*'
)
)
->columns([...])
->defaultSort('Tanggal', 'desc')
->filters([
DateRangeFilter::make('Tanggal')
->query(function ($query) {
$filter = request()->all();
if (isset($filter['start']) && isset($filter['end'])) {
$startDate = Carbon::parse($filter['start']);
$endDate = Carbon::parse($filter['end'])->endOfDay();

$query->whereBetween('transaksi_keluars.tgl_penjualan', [
$startDate,
$endDate,
]);
}
}),
]);
}
2 replies
FFilament
Created by Rojak on 9/28/2024 in #❓┊help
Date Range Filter Plugin Error
No description
4 replies
FFilament
Created by Rojak on 6/8/2024 in #❓┊help
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);
}
2 replies