<?php

namespace SHServ\Entities\Traits;

use \SHServ\Entities\Area;

trait AreaPlacing {
	public function place_in_area(Area $area): bool {
		return $this -> place_in_area_id($area -> id());
	}

	public function place_in_area_id(int $area_id): bool {
		$this -> area_id = $area_id;
		return $this -> update() ? true : false;
	}

	public function parent_area(): Area | null {
		if(!$this -> area_id) {
			return null;
		}

		return new Area($this -> area_id);
	}
}