I am trying to count the total for each medication listed and break it down by the total of each medication and then total by location. All of this data is in one table. The controller I am using to get each medication is below. I am trying to determine if I have to write a query for each tally I am looking for, or do I need to do a php count function for each, or does laravel have something to make this less time consuming?
enter code here public function index()
{
$medications = ControlledSubstances::with('Medications', 'Locations')->paginate('10');
$rx = Medications::where('controlled', '1')->get()
->keyBy('id')
->map(function ($rx){
return"{$rx->trade_name} - {$rx->brand_name}";
});
$cs = Medications::get();
$nb = NarcoticBoxes::get()
->keyBy('id')
->map(function ($nb){
return"{$nb->box_number}";
});
$status = VialStatus::get()
->keyBy('id')
->map(function ($status){
return"{$status->label}";
});
return view('logistics.controlled', compact('medications', 'rx', 'nb', 'status', 'cs'))->with('success', 'New Controlled Substance Added');
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire