<?php
namespace Modules\Cms_plataformas\Models;

use App\Models\BaseModel;

class Model_cms_plataformas extends BaseModel {
	public function getCadastros() {
		$table 			= "cms_plataformas";
		$builder  	= $this->db->table($table);
		$query    	= $builder->get();

		return $query->getResult();
	}

	public function cadastrando() {
		$table 		= "cms_plataformas";
		$builder  = $this->db->table($table);
		$query    = $builder->insert($_POST);

		return $this->db->insertID();
	}

	public function alterar($id) {
		$table 		= "cms_plataformas";
		$builder  = $this->db->table($table)->where('id', $id);
		$query    = $builder->get();

		return $query->getRow();
	}

	public function alterando($id) {
		$table 		= "cms_plataformas";
		$builder  = $this->db->table($table);
		
		$builder->set('data_alteracao', date("Y-m-d H:i:s"));
		$builder->where('id', $id);
		$builder->update($_POST);

		return $id;
	}

	public function deletar($id) {
		$table 		= "cms_plataformas";
		$builder  = $this->db->table($table);
		
		$builder->where('id', $id);
		$builder->delete();
	}
}