MedicOneSystems / MedicOneSystems/livewire-datatables
Can't mix 2 columns one is calculated and the other one is from the original table
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I'm using Laravel framework and I installed livewire-datatables package to display my tables.
I have 2 tables
class Budget extends Model
{
protected $fillable = ['amount'];
public function prizes(): HasMany
{
return $this->hasMany(Prizes::class);
}
}
class Prizes extends Model
{
protected $fillable = ['budget_id', 'budget'];
public function budget(): BelongsTo
{
return $this->belongsTo(Budget::class);
}
}
I'm trying to display list of budgets and I need to display the total amount of budget and the used amount of budgets in same columns.
** total amount of budget is represented from the "amount" column in budgets table.
** used amount of budget is calculated column represented from the sum of "budget" column from prizes table.
===> I tried to do this but it doesn't work
Column::callback(['budgets.amount', 'prizes.budget:sum'], function ($amount, $budgetSum) {
return $budgetSum . "/" . $amount . "(" . $budgetSum / $amount . ")";
})->label('Used Amount / Total Amount'),
Any Help?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the Column::callback entry point and inspect how the package handles budgets.amount alongside the prizes.budget:sum relation aggregate. Reproduce the reported mixed-column case, then verify that the callback receives both values and produces the requested used/total output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100