<?php

namespace App\Repositories;

use App\Models\Organization;

class OrganizationRepository
{
    /**
     * Tìm theo id (binary) hoặc trả null
     */
    public function find($id)
    {
        return Organization::where('id', $id)->first();
    }

    public function create(array $data)
    {
        return Organization::create($data);
    }

    public function updatePrimaryHue($org, int $hue)
    {
        if (!$org) return null;
        if (!($org instanceof Organization)) {
            $org = $this->find($org);
        }
        if (!$org) return null;
        $org->primary_hue = $hue;
        $org->save();
        return $org;
    }
}
