示例#1
0
 /**
  * Finds a SocialNetwork by its ID or name (case-insensitive)
  * @todo these results should be cached to improve website performance. Ideally, all entries would be fetched at once and inside this method we would retrieve from cache - if not found, run the current implementation
  * @param int|string $id_or_name
  * @param array $columns
  * @return self
  */
 public static function find($id_or_name, $columns = ['*'])
 {
     if (is_numeric($id_or_name)) {
         return parent::find($id_or_name, $columns);
     } else {
         return static::whereRaw('LOWER(name) = ?', [$id_or_name])->firstOrFail();
     }
 }
示例#2
0
<?php

ini_set('html_errors', 'off');
require_once '../../vendor/autoload.php';
$config = (require_once '../../src/config/config.php');
session_start();
$GLOBALS['cache'] = new Memcached();
$GLOBALS['cache']->addServers($config['memcached']);
if (PROD) {
    $GLOBALS['cache']->set('oauth', getenv('IRON_CACHE_TOKEN') . ' ' . getenv('IRON_CACHE_PROJECT_ID') . ' general');
}
/* ************************ CONFIGURES DATABASE ACCESS ************************ */
$db = $config['database'];
\LaravelArdent\Ardent\Ardent::configureAsExternal(['driver' => 'pgsql', 'host' => $db['host'], 'port' => isset($db['port']) ? $db['port'] : null, 'database' => $db['name'], 'username' => $db['user'], 'password' => $db['pass'], 'charset' => 'utf8'], 'en');
/* ************************ CONFIGURES THE API OBJECTS ************************ */
$r = new Luracast\Restler\Restler(PROD);
$r->setBaseUrls('/api');
$skip = ['.', '..'];
foreach (scandir('../../src/API') as $file) {
    if (!in_array($file, $skip)) {
        $name = strtok($file, '.');
        $class = "\\Shop\\API\\{$name}";
        $url = property_exists($class, 'url') ? $class::$url : null;
        $r->addAPIClass($class, $url);
    }
}
$r->addAPIClass(\Luracast\Restler\Explorer::class);
$r->handle();