<?php

namespace SHServ\Entities;

use \SHServ\Entities\Area;
use \SHServ\Models\Scripts;

class Script extends \SHServ\Middleware\Entity {

	use \SHServ\Helpers\MetaImplementation;
	use \SHServ\Entities\Traits\AreaPlacing;

	public static $table_name = "scripts";
	protected static $fields = [
		"id", "area_id", "uniq_name", "type", "state",
		"params_schema", "create_at", "update_at"
	];

	public function __construct(Int $id, Array $data = []){
		parent::__construct(
			self::$table_name,
			$id,
			$data
		);
	}

	public function remove() {
		return $this -> remove_entity();
	}

	public function prepare_to_view(Array $script_from_control): Array {
		return (new Scripts()) -> prepare_script_to_view($this -> type, $script_from_control, $this);
	}
}

