I want to pass an additional parameter from controller to collection resource, Please have a look at the following code, I don't know why It's not working. I might be doing something wron here, please help
Controller
$batchStudents = $batch->students->except($batch->host->id);
$batchStudents->test = 'This is testing';
$students = UserCollection::collection($batchStudents);
Collection:
class UserCollection extends JsonResource {
return [
[...]
'test' => $this->test,
];
}
Current Result:
Cuurently its returning null