I have experienced a 500 server error via Laravel, and no error is being written to the log file. I've verified permissions are OK, and that Laravel can write to the log file. I am unsure what other options I have here.
I have chased the error down to this class, the commented out lines are the lines that are causing the error.
class CollectionResource extends JsonResource
{
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
// 'member_count' => $this->items()->count(),
// 'member_count_today' => $this->items()->whereDate('collection_entries.created_at', Carbon::today()->toDateString())->count(),
// 'member_images' => $this->items->take(10)->pluck('data.picture'),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}
Even when wrapping the code in a trycatch, it still swallows the error and returns a 500 without any response data.
Debugging is enabled, logging is enabled, basic things have been checked and double checked. I don't see how I can get passed this?
I purposely threw a syntax exception, it threw a parse error so I know the trycatch block works, and the code is reaching where it should be.
Upon the second request of this endpoint, it seems to work fine with no changes. It is only this specific endpoint.
Items is a belongsToMany relationship.