<?php
  class UserController extends Controller {

        private User $userModel; // ✅ پراپرٹی define کر دی

    public function __construct(){

      $this->userModel = $this->model('User');
     
    }
     public function database(){
      $input['db_name'] = $_POST['data'][0]?? null;
      $input['db_username'] = $_POST['data'][1]?? null;
      $input['db_password'] = $_POST['data'][2]?? null;
      $input['base_url'] = $_POST['data'][3]?? null;
      file_put_contents("../app/config/db.php",serialize($input));
      echo json_encode("success");

     }
    public function saveUser(){
      
      $username = $_POST['data'][0]?? null;
      $password = $_POST['data'][1]?? null;
      $data = array('username'=>$username,'password'=>$password);
      $user = $this->userModel->register($data);
      echo json_encode($user);
    }


  }