Hi everyone! I'm fairly new on Laravel and currently working on a project using Laravel Nova. I want to use the partition metrics to display the percentage of "Loan Applications Per Company". Basically my table structures are like this:
loan_application: (id, user_id)
user: (id, user_name, company_id)
company: (id, company_name)
I'm a little lost on how I will query that from this partition-metrics function:
public function calculate(Request $request)
{
return $this->count($request, Model::class, 'groupByColumn');
}
Since you're likely counting the relationship and not a column on the table, you'll need to use the result() method. You can query and then map over the result to get the required array. Something like this might work.
public function calculate(Request $request)
{
$companies = Company::with('loan_application')->map(function($company) {
return [
$company->name => $company->loan_application->count()
];
});
return $this->result($companies->all());
}
This is what I'm doing, however, by default Laravel Spark limits the partitions to a total of 5. How can I get the card to show the full list of partitions?