<?php

namespace App\Controllers\Api;

use App\Models\ServiceModel;

class ServicesController extends BaseApiController
{
    /**
     * GET api/services
     */
    public function index()
    {
        $model = model(ServiceModel::class);
        $list  = $model->where('status', 'active')->findAll();
        $data  = array_map(static function ($row) {
            return [
                'id'        => (int) $row->id,
                'name'      => $row->name,
                'base_fee'  => (float) $row->base_fee,
                'image_url' => isset($row->image_url) && $row->image_url !== '' ? $row->image_url : null,
            ];
        }, $list);
        return $this->success($data);
    }
}
