<?php

namespace App\Models;

use App\Core\Model;

class User extends Model
{
    protected $table = 'users';

    public function create($data)
    {
        $sql = "INSERT INTO users (name, email, password, role, client_id) VALUES (:name, :email, :password, :role, :client_id)";
        $stmt = $this->conn->prepare($sql);
        return $stmt->execute([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => password_hash($data['password'], PASSWORD_DEFAULT),
            'role' => $data['role'] ?? 'client',
            'client_id' => $data['client_id'] ?? null
        ]);
    }
}
