This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title> React JS Email Check </title> | |
<link rel="stylesheet" href="bundles/bundle.css"> | |
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,500,600,700" rel="stylesheet"> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script type="text/javascript" src="bundles/bundle.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$api->group('/api', function () use ($api) { | |
$api->group('/v1', function () use ($api) { | |
/** Get all Products */ | |
$api->get('/products?', '\BestShop\v1\Product:getProducts')->name('get_products'); | |
/** Add a Product */ | |
$api->post('/products?', '\BestShop\v1\Product:addProduct')->name('add_products'); | |
/** Get a single Product */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getCategories() { | |
$api = $this->api; | |
// Build query | |
$sql = new DbQuery(); | |
// Build SELECT | |
$sql->select('category.*'); | |
// Build FROM | |
$sql->from('category', 'category'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace BestShop\Product; | |
use Db; | |
use BestShop\Database\DbQuery; | |
use BestShop\ObjectModel; | |
class Category extends ObjectModel { | |
/** @var $id Category ID */ | |
public $id; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function updateProduct($productId ) { | |
$api = $this->api; | |
$payload = $api->request()->post(); | |
$product = new ProductObject( (int) $productId ); | |
if(!Validate::isLoadedObject($product)) { | |
$api->response->setStatus(404); | |
return $api->response([ | |
'success' => false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function deleteProduct( $productId ) { | |
$api = $this->api; | |
$product = new ProductObject( (int) $productId ); | |
if(!Validate::isLoadedObject($product)) { | |
$api->response->setStatus(404); | |
return $api->response([ | |
'success' => false, | |
'message' => 'Product was not found' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name" : "Amazing Pillow 2.0", | |
"price" : "57", | |
"description" : "The best pillow for amazing programmers.", | |
"category_id" : 5 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getProduct( $productId ) { | |
$api = $this->api; | |
$product = new ProductObject( (int) $productId ); | |
if(!Validate::isLoadedObject($product)) { | |
return $api->response([ | |
'success' => false, | |
'message' => 'Product was not found' | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getProducts() { | |
$api = $this->api; | |
// Build query | |
$sql = new DbQuery(); | |
// Build SELECT | |
$sql->select('product.*'); | |
// Build FROM | |
$sql->from('product', 'product'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace BestShop\Product; | |
use Db; | |
use BestShop\Database\DbQuery; | |
use BestShop\ObjectModel; | |
class Product extends ObjectModel { | |
/** @var $id Product ID */ | |
public $id; |