This file contains 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 | |
$model_confg = array( | |
"Models" => | |
array(array('className'=> "Books", 'classTable'=>'books', "fillable" => "book_name"), array('className'=> "Authors", 'classTable'=>'authors', "fillable" => "")), | |
"Relations" => | |
array("Authors" => | |
array("books" => | |
array("function" => function( $self ) { | |
return $self->belongsToMany('Books'); |
This file contains 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 | |
$connection = new MongoClient( "mongodb://" ); | |
$db = $connection->parseforce; | |
function one_to_one_select($flow = array(), $collection) { | |
//if(MongoId::isValid($value)) { | |
$data = array(); | |
if($flow['where']['pointer'] == "_id") { |
This file contains 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 | |
$flow = array( | |
"api_endpoint" => $this->get('from'), | |
"index" => $this->get("index"), // leave blank for an all query | |
"where" => array("pointer" => "id", | |
"table" => "events", | |
"type" => "MANY_TO_ONE") | |
); | |
if($flow['where']['type'] == "MANY_TO_ONE") { |
This file contains 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
create_table :orders do |t| | |
t.string 'name' | |
end | |
add_index :orders, :tags, using: 'gin' | |
add_index :orders, :ratings, using: 'gin' | |
# app/models/order.rb | |
class Order < ApplicationRecord | |
end | |
This file contains 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
module Orders | |
class API < Grape::API | |
version 'v1', using: :header, vendor: 'invoate' | |
format :json | |
prefix :api | |
helpers do | |
def current_user | |
@current_user ||= User.authorize!(env) | |
end |
This file contains 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 | |
// Requests for PHP Code | |
$endpoint = "https://{$data['account']}.harvestapp.com/invoices"; | |
$hashAuth = base64_encode($data['username'].":".$data['password']); | |
$response = Requests::get($endpoint, array('Content-Type' => 'application/json', | |
'accept' => 'application/json', | |
'authorization' => "Basic ". $hashAuth)); |