/** * @param string|aray $model * @return \Lassi\App\Controller */ public function __construct(Lassi $lassi = null, $models = null) { if ($lassi !== null) { $this->lassi = $lassi; $this->setApp($lassi->getApp()); } if ($models !== null) { $this->useModel($models); } return $this; }
/** * Set model(s) to use * * @param string|array $models * * @return $this */ public function useModel($models) { if (is_array($models)) { return array_map(array($this, 'useModel'), $models); } if (is_scalar($models)) { $name = strtolower($models); $class = sprintf('\\Lassi\\Model\\%s', ucwords($name)); $this->{$name} = new $class(); $this->{$name}->setConnection($this->lassi->getEloquent()); } return $this; }
/** * Load framework app routes * @return void */ private static function loadRoutes() { $routes = dirname(__FILE__) . '/routes.php'; if (!file_exists($routes) || !is_readable($routes)) { throw new NotFoundException('Routes not found.'); } // Get Slim instance $app = \Lassi\Lassi::getInstance()->getApp(); require_once $routes; }
public function __construct() { /** * Set app instance for parent class */ parent::__construct(Lassi::getInstance()); /** * Set a single model or an array of models */ $this->useModel('user'); }
<?php use Lassi\Lassi; /** * Bootstrap the boilerplate * * @author Jabran Rafique <*****@*****.**> * @license MIT License */ /** Restrict direct access */ defined('ROOT') or die('Unexpected request'); /** * Setup Lassi with Slim framework and Eloquent */ Lassi::bootstrap();
public function testGetInstanceReturnsLassiInstance() { Util::setEnvVariables('.'); $this->assertInstanceOf('Lassi\\Lassi', Lassi::getInstance()); }