<?php namespace NetSTI\Hotel\Components;

use Lang;
use Flash;
use Validator;
use ValidationException;
use NetSTI\Hotel\Models\Roomtype as RoomModel;

class RoomTypes extends \Cms\Classes\ComponentBase
{
	public function componentDetails()
	{
		return [
			'name' => 'netsti.hotel::lang.roomstype.plural',
			'description' => 'netsti.hotel::lang.roomstype.description'
		];
	}

	public function onRun(){
		if (is_numeric($id = $this->property('itemId'))) {
			$this->page['roomtype'] = RoomModel::whereId($id)->with('picture')->first();
		} else {
			$this->page['roomstype'] = RoomModel::all();
		}
	}
}
?>