<?php

namespace App\Http\Resources;

use Illuminate\Support\Facades\DB;
use Illuminate\Http\Resources\Json\JsonResource;

class PollOptionResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'text' => $this->option_text,
            'votes' => DB::table('poll_votes')->where('option_id', $this->id)->count(),
            
        ];
    }
}