Skip to content

Commit

Permalink
Versão 0.1 Alpha
Browse files Browse the repository at this point in the history
* Primeira versão
  • Loading branch information
JP Rodrigues committed May 19, 2016
1 parent 89c3da0 commit 8c33d26
Show file tree
Hide file tree
Showing 41 changed files with 1,323 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendors/gainTime"]
path = vendors/gainTime
url = https://github.com/GainTime/gainTime
10 changes: 10 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RewriteEngine on
#ErrorDocument 404 http://
#ErrorDocument 403 http://
#ErrorDocument 500 http://
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.phtml -f
RewriteRule ^(.*)$ $1.phtml
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options -Indexes
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
# plus
Abstração de CRUD em php para o GainTime
# plus GainTime
###### Versão de desenvolvimento

**Abstração de CRUD em php para o GainTime**


### Model
Você vai utilizar a `./lib/model/base.php` para dar um `extends` da nossa `\Model\Base` em sua model.

```php
require_once('../lib/model/base.php');

class User extends \Model\Base
{
public $fillable = ['id', 'name', 'email', 'level'];
}

```

Isto é tudo o que você precisa para utilizar as funções básicas de um CRUD.

IMPORTANTE: Para utilizar a `\Model\Base`, suas funções e propriedades corretamente, você vai precisar nomear suas tabelas do banco de dados com o mesmo nome da model correpondente acrescido de s.
```
- Model: User
- Correspondent database table: users
```

... we'll continue
25 changes: 25 additions & 0 deletions controllers/company_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
require_once('../models/company.php');
require_once('../lib/controller/base.php');
class Company_controller extends \Controller\Base {
function __construct() {
$this->location = '../views/contact';
$this->model = self::get_model();
}
}

$postActions = array('store', 'login');
$getActions = array('delete');

$call = new Company_controller();

if(isset($_POST['action']) && in_array($_POST['action'], $postActions)) {
$call->$_POST['action']();
}
elseif((key($_GET))!==null && in_array(key($_GET), $getActions)) {
$command = key($_GET);
$call->$command();
}
else {
header('Location: ../');
}
33 changes: 33 additions & 0 deletions controllers/partner_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
require_once('../models/partner.php');
require_once('../lib/controller/base.php');

class Partner_controller extends \Controller\Base {
function __construct() {
$this->location = '../views/partners';
$this->model = self::get_model();
}

public static function is_valid() {
if ($_POST['name'] != "" && $_POST['description'] != "") {
return true;
}
return false;
}
}

$postActions = array('store');
$getActions = array('delete');

$call = new Partner_controller();

if(isset($_POST['action']) && in_array($_POST['action'], $postActions)) {
$call->$_POST['action']();
}
elseif((key($_GET))!==null && in_array(key($_GET), $getActions)) {
$command = key($_GET);
$call->$command();
}
else {
header('Location: ../');
}
33 changes: 33 additions & 0 deletions controllers/project_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
require_once('../models/project.php');
require_once('../lib/controller/base.php');

class Project_controller extends \Controller\Base {
function __construct() {
$this->location = '../views/projects';
$this->model = self::get_model();
}

public static function is_valid() {
if ($_POST['name'] != "" && $_POST['description'] != "") {
return true;
}
return false;
}
}

$postActions = array('store');
$getActions = array('delete');

$call = new Project_controller();

if(isset($_POST['action']) && in_array($_POST['action'], $postActions)) {
$call->$_POST['action']();
}
elseif((key($_GET))!==null && in_array(key($_GET), $getActions)) {
$command = key($_GET);
$call->$command();
}
else {
header('Location: ../');
}
33 changes: 33 additions & 0 deletions controllers/service_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
require_once('../models/service.php');
require_once('../lib/controller/base.php');

class Service_controller extends \Controller\Base {
function __construct() {
$this->location = '../views/services';
$this->model = self::get_model();
}

public static function is_valid() {
if ($_POST['title'] != "" && $_POST['description'] != "") {
return true;
}
return false;
}
}

$postActions = array('store');
$getActions = array('delete');

$call = new Service_controller();

if(isset($_POST['action']) && in_array($_POST['action'], $postActions)) {
$call->$_POST['action']();
}
elseif((key($_GET))!==null && in_array(key($_GET), $getActions)) {
$command = key($_GET);
$call->$command();
}
else {
header('Location: ../');
}
34 changes: 34 additions & 0 deletions controllers/user_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
require_once('../models/user.php');
require_once('../lib/controller/base.php');

class User_controller extends \Controller\Base {

function __construct() {
$this->location = '../views/users';
$this->model = self::get_model();
}

public static function is_valid() {
if ($_POST['name'] != "" && $_POST['email'] != "" && $_POST['level'] != "") {
return true;
}
return false;
}
}

$postActions = array('store', 'login');
$getActions = array('delete');

$call = new User_controller();

if(isset($_POST['action']) && in_array($_POST['action'], $postActions)) {
$call->$_POST['action']();
}
elseif((key($_GET))!==null && in_array(key($_GET), $getActions)) {
$command = key($_GET);
$call->$command();
}
else {
header('Location: ../');
}
5 changes: 5 additions & 0 deletions db/create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- -----------------------------------------------------
-- Schema default
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `default` ;
CREATE SCHEMA IF NOT EXISTS `default` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
151 changes: 151 additions & 0 deletions db/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Table `users`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`email` VARCHAR(255) NOT NULL,
`password` VARCHAR(32) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`level` INT NOT NULL,
`createdAt` DATETIME,
`updatedAt` DATETIME,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `idusers_UNIQUE` (`id` ASC) ,
UNIQUE INDEX `email_UNIQUE` (`email` ASC))
ENGINE = InnoDB;

-- -----------------------------------------------------
-- View 'users_vw'
-- -----------------------------------------------------
DROP VIEW IF EXISTS `users_vw`;
CREATE VIEW `users_vw` AS select
`users`.`id` AS `id`,
`users`.`name` AS `name`,
`users`.`email` AS `email`,
`users`.`level` AS `level`
from (`users`);

-- -----------------------------------------------------
-- Table `projects`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `projects`;
CREATE TABLE IF NOT EXISTS `projects` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`description` TEXT NOT NULL,
`createdAt` DATETIME,
`updatedAt` DATETIME,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `idprojects_UNIQUE` (`id` ASC))
ENGINE = InnoDB;

-- -----------------------------------------------------
-- View 'projects_vw'
-- -----------------------------------------------------
DROP VIEW IF EXISTS `projects_vw`;
CREATE VIEW `projects_vw` AS select
`projects`.`id` AS `id`,
`projects`.`title` AS `title`,
`projects`.`description` AS `description`
from (`projects`);

-- -----------------------------------------------------
-- Table `services`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `services`;
CREATE TABLE IF NOT EXISTS `services` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`description` TEXT NOT NULL,
`image` TEXT,
`createdAt` DATETIME,
`updatedAt` DATETIME,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `idservices_UNIQUE` (`id` ASC))
ENGINE = InnoDB;

-- -----------------------------------------------------
-- View 'services_vw'
-- -----------------------------------------------------
DROP VIEW IF EXISTS `services_vw`;
CREATE VIEW `services_vw` AS select
`services`.`id` AS `id`,
`services`.`title` AS `title`,
`services`.`description` AS `description`,
`services`.`image` AS `image`
from (`services`);

-- -----------------------------------------------------
-- Table `partners`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `partners`;
CREATE TABLE IF NOT EXISTS `partners` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`description` TEXT NOT NULL,
`image` TEXT,
`createdAt` DATETIME,
`updatedAt` DATETIME,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `idpartners_UNIQUE` (`id` ASC))
ENGINE = InnoDB;

-- -----------------------------------------------------
-- View 'partners_vw'
-- -----------------------------------------------------
DROP VIEW IF EXISTS `partners_vw`;
CREATE VIEW `partners_vw` AS select
`partners`.`id` AS `id`,
`partners`.`name` AS `name`,
`partners`.`description` AS `description`,
`partners`.`image` AS `image`
from (`partners`);

-- -----------------------------------------------------
-- Table `companys`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `companys`;
CREATE TABLE IF NOT EXISTS `companys` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`company` VARCHAR(255),
`description` TEXT,
`address` VARCHAR(255),
`city` VARCHAR(255),
`map` VARCHAR(255),
`room` VARCHAR(255),
`phone` VARCHAR(255),
`email` VARCHAR(255),
`facebook` VARCHAR(255),
`instagram` VARCHAR(255),
`linkedin` VARCHAR(255),
`createdAt` DATETIME,
`updatedAt` DATETIME,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `idcompany_UNIQUE` (`id` ASC))
ENGINE = InnoDB;

-- -----------------------------------------------------
-- View 'company_vw'
-- -----------------------------------------------------
DROP VIEW IF EXISTS `companys_vw`;
CREATE VIEW `companys_vw` AS select
`companys`.`id` AS `id`,
`companys`.`company` AS `company`,
`companys`.`description` AS `description`,
`companys`.`address` AS `address`,
`companys`.`city` AS `city`,
`companys`.`map` AS `map`,
`companys`.`room` AS `room`,
`companys`.`phone` AS `phone`,
`companys`.`email` AS `email`,
`companys`.`facebook` AS `facebook`,
`companys`.`instagram` AS `instagram`,
`companys`.`linkedin` AS `linkedin`
from (`companys`);
Loading

0 comments on commit 8c33d26

Please sign in to comment.