Exemple #1
0
 public static function destroy($outlets, $id = null)
 {
     $serviceIds = $dealIds = $outletIds = [];
     if (!empty($outlets)) {
         if ($id) {
             array_push($outletIds, $id);
         } else {
             foreach ($outlets as $key => $outlet) {
                 array_push($outletIds, $outlet->id);
             }
         }
         $services = Service::whereIn('outlet_id', $outletIds)->get();
         foreach ($services as $key => $service) {
             array_push($serviceIds, $service->id);
         }
         // delete deal
         $deals = Deal::whereIn('service_id', $serviceIds)->get();
         foreach ($deals as $key => $deal) {
             array_push($dealIds, $deal->id);
         }
         // delete deal transaction
         DealTransaction::whereIn('deal_id', $dealIds)->delete();
         Deal::whereIn('id', $dealIds)->delete();
         Service::whereIn('id', $serviceIds)->delete();
         Outlet::whereIn('id', $outletIds)->delete();
     }
 }
Exemple #2
0
 protected function openSession($configClassesArray, $enableAutoload = false)
 {
     $config = $this->createConfigArray($configClassesArray, new PDO(MYSQL_DSN, MYSQL_USER, MYSQL_PASSWORD));
     $config['connection']['dialect'] = 'mysql';
     $config['proxies'] = array('autoload' => true);
     return Outlet::openSession(new OutletConfig($config));
 }
 function __construct($locations = NULL)
 {
     $dbdir = any($locations['tmp'], 'tmp');
     if (class_exists("Outlet")) {
         Outlet::init(array('connection' => array('type' => 'datamanager'), 'classes' => array()));
         $this->outlet =& Outlet::getInstance();
     }
 }
 protected function openSession($configClassesArray, $enableAutoload = false)
 {
     if (!$enableAutoload) {
         return Outlet::openSession($this->createConfig($configClassesArray));
     } else {
         $config = $this->createConfigArray($configClassesArray);
         $config['proxies'] = array('autoload' => true);
         return Outlet::openSession(new OutletConfig($config));
     }
 }
 public function postAddoutlets()
 {
     $outlet = new Outlet();
     $outlet->user_id = Input::get('user_id');
     $outlet->address1 = Input::get('address1');
     $outlet->address2 = Input::get('address2');
     $outlet->city = Input::get('city');
     $outlet->pincode = Input::get('pincode');
     $outlet->phone = Input::get('phone');
     $arr = Input::get('delivery_options');
     $output = "";
     foreach ($arr as $key => $value) {
         $output .= $value . ",";
     }
     $output = rtrim($output, ",");
     $outlet->delivery_options = $output;
     $outlet->save();
     return Redirect::to('admin/outlets/index');
 }
 public function run()
 {
     DB::statement("TRUNCATE TABLE outlets");
     $adminId = User::select('id')->where('username', 'dungho')->first()->id;
     $retailerMT = Retailer::select('id')->where('company_register_id', 'MT00001')->first()->id;
     $retailerPL = Retailer::select('id')->where('company_register_id', 'PL00001')->first()->id;
     $outlets = array(array('name' => 'Minh Toan Graxy - Spa Beauty', 'outlet_register_id' => 'MTID001', 'website' => 'www.minhtoan.com.vn', 'retailer_id' => $retailerMT), array('name' => 'Minh Toan Graxy - Spa One', 'outlet_register_id' => 'MTID002', 'website' => 'www.minhtoan.com.vn', 'retailer_id' => $retailerMT), array('name' => 'Minh Toan Graxy - Spa Two', 'outlet_register_id' => 'MTID003', 'website' => 'www.minhtoan.com.vn', 'retailer_id' => $retailerMT), array('name' => 'Phi Lu - Spa Beauty', 'outlet_register_id' => 'PLID001', 'website' => 'www.philu.com.vn', 'retailer_id' => $retailerPL));
     foreach ($outlets as $key => $value) {
         $outlet = new Outlet();
         $outlet->name = $value['name'];
         $outlet->address_id = rand(1, 5);
         $outlet->outlet_register_id = $value['outlet_register_id'];
         $outlet->website = $value['website'];
         $outlet->admin_id = $adminId;
         $outlet->description_id = 1;
         $outlet->status = 'active';
         $outlet->retailer_id = $value['retailer_id'];
         $outlet->save();
     }
 }
 public function pelangganOutlet()
 {
     $term = Input::get('term');
     $outlet = Outlet::where('user_id', Auth::user()->id)->first();
     $data = OutletPelanggan::distinct()->select('nama', 'id', 'telp')->where('outlet_laundry_id', $outlet->id)->where('nama', 'LIKE', '%' . $term . '%')->groupBy('id')->take(15)->get();
     $result = [];
     foreach ($data as $d) {
         if (strpos(Str::lower($d), $term) !== false) {
             $result[] = ['value' => $d->nama, 'id' => $d->id, 'telp' => $d->telp];
         }
     }
     return Response::json($result);
 }
 public function getChildren($obj)
 {
     $outlet = Outlet::getInstance();
     $cls = $this->cls;
     $left = $this->left;
     $right = $this->right;
     // qualifiers
     $w = '';
     foreach ($this->qualifiers as $field) {
         $w .= "{n.{$field}} = " . $outlet->quote($obj->{$field}) . " AND ";
     }
     $children = $outlet->from("{$cls} n")->leftJoin("{" . "{$cls} parent} ON ({parent.{$left}} < {n.{$left}} AND {parent.{$right}} > {n.{$right}})")->where("\n\t\t\t\t\t{$w}\n\t\t\t\t\t{n.{$left}} > ?\n\t\t\t\t\tAND {n.{$right}} < ?\n\t\t\t\t\tAND {parent.{$left}} >= ?\n\t\t\t\t\t\n\t\t\t\t", array($obj->Left, $obj->Right, $obj->Left))->select("COUNT({parent.{$left}})")->groupBy("{n.{$left}}, {n.{$right}}")->having("COUNT({parent.{$left}}) = 1")->find();
     return $children;
 }
 function testMap()
 {
     $outlet = Outlet::getInstance();
     $p = new Project();
     $p->setName('Project 1');
     $outlet->save($p);
     $p_map = $outlet->select('Project', 'where {Project.ProjectID} = ?', array($p->getProjectID()));
     $p_map = $p_map[0];
     $this->assertTrue($p === $p_map, 'Diferent object on identity map');
     $outlet->clearCache();
     $p_map = $outlet->select('Project', 'where {Project.ProjectID} = ?', array($p->getProjectID()));
     $p_map = $p_map[0];
     $this->assertTrue($p !== $p_map, 'Equal object on identity map');
 }
 function testUpdateAfterRelationshipUpdate()
 {
     $outlet = Outlet::getInstance();
     $p = new Project();
     $p->setName('Name 1');
     $b = new Bug();
     $b->Title = 'Test Bug';
     $p->addBug($b);
     $outlet->save($p);
     $projectid = $p->getProjectID();
     $p->setName('Name 2');
     $outlet->save($p);
     $p = $outlet->load('Project', $projectid);
     $this->assertEquals($p->getName(), 'Name 2');
 }
 function controller_playlist($args, $output = "inline")
 {
     $vars["args"] = $args;
     $mpdplaylistnames = $this->playlist->getPlaylists();
     $vars["currentplaylist"] = $this->playlist->getPlaylistInfo();
     $status = $this->playlist->getStatus();
     if (!empty($mpdplaylistnames)) {
         $outlet = Outlet::getInstance();
         $dbplaylists = $outlet->select("AudioPlaylist", "ORDER BY {AudioPlaylist.last_listened} DESC");
         foreach ($dbplaylists as $playlist) {
             $vars["playlists"][] = $playlist;
         }
     } else {
         print_pre("ERROR: MPD has no playlists!");
     }
     return $this->GetTemplate("./playlist.tpl", $vars);
 }
Exemple #12
0
 function controller_orm($args)
 {
     /*
         if (!User::authorized("orm"))
           throw new Exception("not allowed");
     */
     $ret = $this->GetComponentResponse("./orm.tpl");
     /*
     $user = User::singleton();
     if (!($user->isLoggedIn() && $user->HasRole("ORM"))) // display the access violation message
       $ret->SetTemplate("access_violation.tpl");
     */
     if (!empty($args["ormaction"]) && !empty($args["model"])) {
         $ret["model"] = $args["model"];
         $ret["ormcfg"] = new OrmModel($args["model"]);
         if ($args["ormaction"] == "create" && !empty($args["classname"])) {
             $ormclass = new OrmClass($ret["ormcfg"]->classes->{$args["classname"]});
             //$sql = $ormclass->getCreateSql();
             $sqlkey = "db." . $ormclass->table . ".create:nocache";
             /*
                     print_pre($ormclass->table);
                     print_pre($ormclass->getColumns());
             */
             $outlet = Outlet::getInstance();
             $pdo = $outlet->getConnection()->getPDO();
             if ($pdo) {
                 $ret["sql"] = $ormclass->getCreateSQL();
                 try {
                     $pdo->query($ret["sql"]);
                     $ret["success"] = "Table '{$ormclass->table}' created successfully";
                 } catch (Exception $e) {
                     $ret["error"] = $e->getMessage();
                 }
             }
             /*
             $data = DataManager::singleton();
             $data->QueryCreate($sqlkey, $ormclass->table, $ormclass->getColumns($sql));
             */
         }
     }
     return $ret;
 }
Exemple #13
0
 public function getTimeSlot($service_id)
 {
     Activity::log(['contentId' => $service_id, 'contentType' => 'Outlet', 'action' => 'getTimeSlot', 'description' => 'getTimeSlot of Service', 'details' => 'Service Id: ' . $service_id, 'updated' => false]);
     $service = Service::find($service_id);
     $outlet = Outlet::find($service->outlet_id);
     $startTime = explode(':', $outlet->startTime);
     $endTime = explode(':', $outlet->endTime);
     if (count($startTime) < 2 || count($endTime) < 2) {
         return array();
     }
     $start = mktime($startTime[0], $startTime[1], 0, 8, 12, 2014);
     $end = mktime($endTime[0], $endTime[1], 0, 8, 12, 2014);
     $hourArray = array();
     $count = 1;
     $hourArray[] = $start;
     while ($start < $end && $count < 1000) {
         $date = $start + $service->time_operate * 60;
         $hourArray[] = $date;
         $start = $date;
         $count++;
     }
     return $hourArray;
 }
Exemple #14
0
 function importCategories()
 {
     $catfile = file_get_contents("/home/bai/yelp-categories.txt");
     $catstruct = array('', 'what');
     $levels = array('0' => 0, '#' => 1, '*' => 2, 'o' => 3, '+' => 4);
     $lastsymbol = '#';
     foreach (explode("\n", $catfile) as $line) {
         if (preg_match("/^\\s*?([#*o+])\\s+(.*?)\\s+\\(([^)]*?)\\)\\s*\$/", $line, $m)) {
             $diff = $levels[$m[1]] - $levels[$lastsymbol];
             #print "(" . $1 . " vs " . $lastsymbol . ") " . $levels{$1} . " > " . $levels{$lastsymbol} ." ? $diff\n";
             if ($diff > 0) {
                 array_push($catstruct, $m[3]);
                 #print "go down a level\n";
             } else {
                 if ($diff < 0) {
                     for ($i = 0; $i > $diff; $i--) {
                         #print "POP ";
                         array_pop($catstruct);
                     }
                     #      print "go up a level\n";
                     $catstruct[count($catstruct) - 1] = $m[3];
                 } else {
                     $catstruct[count($catstruct) - 1] = $m[3];
                     #      print "SET IT TO $3";
                 }
             }
             print "send {$m['3']} for '{$m['2']}' (parent is " . $catstruct[count($catstruct) - 2] . ")\n";
             $category = new NavigationLocationCategory();
             $category->categoryid = $m[3];
             $category->name = $m[2];
             $category->parent = $catstruct[count($catstruct) - 2];
             $outlet = Outlet::getInstance();
             $outlet->Save($category);
             $lastsymbol = $m[1];
         }
     }
 }
 function setUp()
 {
     // create database
     $pdo = Outlet::getInstance()->getConnection();
     switch (DATABASE_DRIVER) {
         case 'mysql':
             OutletTestSetup::createMySQLTables($pdo);
             break;
         case 'pgsql':
             OutletTestSetup::createPostgresTables($pdo);
             break;
         case 'sqlite':
         default:
             OutletTestSetup::createSQLiteTables($pdo);
     }
     $pdo->exec('DELETE FROM projects');
     $pdo->exec('DELETE FROM addresses');
     $pdo->exec('DELETE FROM bugs');
     $pdo->exec('DELETE FROM machines');
     $pdo->exec('DELETE FROM users');
     $pdo->exec('DELETE FROM watchers');
     $pdo->exec('DELETE FROM profiles');
     parent::setUp();
 }
 static function toArray($entity)
 {
     if (!$entity) {
         throw new OutletException('You must pass an entity');
     }
     $class = self::getEntityClass($entity);
     $arr = array();
     foreach (Outlet::getInstance()->getConfig()->getEntity($class)->getProperties() as $key => $p) {
         $arr[$key] = self::toSqlValue($p, self::getProp($entity, $key));
     }
     return $arr;
 }
 /**
  * Show the form for editing the specified resource.
  * GET /outlets/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $outlet = Outlet::where('user_id', Auth::user()->id)->first();
     $pemasukan = OutletPemasukan::findOrFail($id);
     $status = ['1' => 'Masuk', '2' => 'Proses', '3' => 'Selesai', '4' => 'Diambil'];
     return View::make('admin.outlets.edit', compact('outlet', 'pemasukan', 'status'));
 }
Exemple #18
0
<?php

// set this to mysql, mssql, or sqlite
define('DATABASE_DRIVER', 'sqlite');
set_include_path(dirname(__FILE__) . '/../classes' . PATH_SEPARATOR . get_include_path());
// outlet
require_once 'outlet/Outlet.php';
require_once 'entities.php';
// basic setup
switch (DATABASE_DRIVER) {
    case 'sqlite':
        $conf = (include 'outlet-config-sqlite.php');
        break;
    case 'mysql':
        $conf = (include 'outlet-config-mysql.php');
        break;
    case 'pgsql':
        $conf = (include 'outlet-config-pgsql.php');
        break;
    default:
        throw new Exception('Unsupported database driver: ' . DATABASE_DRIVER);
}
Outlet::init($conf);
Outlet::getInstance()->createProxies();
Exemple #19
0
<?php

require_once 'config.php';
require '../classes/User.php';
$session = Outlet::openSession();
// Create
echo "Creating...\n";
$user = new User();
$user->ID = 1;
$user->Username = '******';
$session->save($user)->clear();
// Clears cache
echo "Created\n";
// Load
echo "Loading...\n";
$user = $session->load('User', 1);
echo "Loaded\n";
// Update
echo "Updating...\n";
$user->Username = '******';
$user = $session->flush()->clear()->load('User', 1);
// Reloads from DB
echo "Updated\n";
// Delete
echo "Deleting...\n";
$session->delete($user);
echo "Deleted\n";
 function getUser()
 {
     if (is_null($this->UserID)) {
         return parent::getUser();
     }
     if (is_null(parent::getUser()) && $this->UserID) {
         parent::setUser(Outlet::getInstance()->load('User', $this->UserID));
     }
     return parent::getUser();
 }
 /**
  * Show the form for editing the specified service.
  *
  * @param  int  $id
  * @return Response
  */
 public function editService($service)
 {
     if ($service->status == 'active') {
         $title = Lang::get('site/services/title.service_update');
     } else {
         $title = Lang::get('site/services/title.create_a_new_service');
     }
     $outlets = Outlet::active()->owner()->lists('name', 'id');
     $images = Picture::getByRefId($service->id, 'service');
     return View::make('site.services.edit', compact('service', 'outlets', 'title'))->nest('imageForm', 'site.partials.image.create', ['refId' => $service->id, 'type' => 'service', 'images' => $images]);
 }
 function controller_location_categories($args, $output = "inline")
 {
     $targetid = !empty($args["targetid"]) ? $args["targetid"] : "index_content";
     if (isset($args["showcategory"])) {
         if (is_array($args["showcategory"])) {
             $_SESSION["navigation"]["location"]["categories"] = array();
             foreach ($args["showcategory"] as $cat => $enabled) {
                 if ($enabled) {
                     $_SESSION["navigation"]["location"]["categories"][] = $cat;
                 }
             }
         } else {
             if (!empty($args["showcategory"])) {
                 $_SESSION["navigation"]["location"]["categories"] = explode(" ", $args["showcategory"]);
             } else {
                 unset($_SESSION["navigation"]["location"]["categories"]);
             }
         }
     }
     if (!empty($args["root"])) {
         $vars["toplevel"] = false;
         $vars["root"] = $args["root"];
     } else {
         $outlet = Outlet::getInstance();
         $categories = $outlet->select("NavigationLocationCategory");
         $vars["toplevel"] = true;
         $vars["categories"] = NULL;
         $vars["root"]->children = array();
         for ($i = 0; $i < count($categories); $i++) {
             if (!isset($categories[$i]->children)) {
                 $categories[$i]->children = array();
             }
             $vars["categories"][$categories[$i]->categoryid] =& $categories[$i];
             if (!empty($categories[$i]->parent)) {
                 $vars["categories"][$categories[$i]->parent]->children[] =& $categories[$i];
             } else {
                 $vars["root"]->children[] =& $categories[$i];
             }
             if (!empty($_SESSION["navigation"]["location"]["categories"])) {
                 $categories[$i]->enabled = in_array($categories[$i]->categoryid, $_SESSION["navigation"]["location"]["categories"]);
             }
         }
     }
     $page = $this->GetTemplate("./location_categories.tpl", $vars);
     if ($output == "ajax") {
         $ret[$targetid] = $page;
     } else {
         $ret = $page;
     }
     return $ret;
 }
Exemple #23
0
<?php

set_include_path(dirname(__FILE__) . '/..' . PATH_SEPARATOR . get_include_path());
require 'outlet/Outlet.php';
require 'outlet/OutletProxyGenerator.php';
Outlet::init(require $_SERVER['argv'][1]);
$conf = (require $_SERVER['argv'][1]);
$gen = new OutletProxyGenerator(Outlet::getInstance()->getConfig());
$s = "<?php\n";
$s .= $gen->generate();
file_put_contents('outlet-proxies.php', $s);
 /**
  * Initialize outlet with an array configuration
  * 
  * @param array $conf configuration
  */
 static function init(array $conf)
 {
     // instantiate
     self::$instance = new self($conf);
 }
Exemple #25
0
 public function postBook()
 {
     $response = null;
     $Bill = null;
     $spa_id = Input::get('spaName');
     $outlet_id = Input::get('spaLocation');
     $service_id = Input::get('serviceName');
     $apptDate = Input::get('apptDate');
     $apptTime = Input::get('timeSlot');
     if (!empty($spa_id) && !empty($outlet_id) && !empty($service_id) && !empty($apptDate)) {
         $apptDateTime = strtotime($apptDate . " " . $apptTime);
         $service = Service::find($service_id);
         $response = array("retailerName" => Retailer::find($spa_id)->name, "outletName" => Outlet::find($outlet_id)->name, "serviceName" => $service->name . " (" . $service->time_operate . " mins)", "apptDateTime" => $apptDateTime, "price" => $service->price);
         if (!Auth::user()) {
             return View::make('site/user/book', compact('response', 'Bill'));
         }
         $deal = Deal::where('service_id', '=', $service_id)->where('deal_type', '=', 'Service')->first();
         if ($deal == null) {
             $deal = new Deal();
             $deal->service_id = $service_id;
             $deal->deal_type = 'Service';
             $deal->title = $service->name;
             $deal->amount = $service->price;
             $deal->discount = 0;
             $deal->special_request = "";
             $deal->status = "active";
             $deal->save();
         }
         $Bill = new DealTransaction();
         $Bill->deal_id = $deal->id;
         $Bill->consumer_id = Auth::user()->id;
         $Bill->consumer_email = Auth::user()->email;
         $Bill->qty = 1;
         $Bill->amount = $service->price;
         $Bill->total = $service->price;
         $Bill->save();
         return View::make('site/user/book', compact('response', 'Bill'));
     }
     return Redirect::to('/');
 }
 public function getSpaLocations($retailer_id)
 {
     Activity::log(['contentId' => $retailer_id, 'contentType' => 'Outlet Location', 'action' => 'GetSpaLocations', 'description' => 'Get Locations of Outlets for an Retailer', 'details' => 'Outlet Id: ' . $retailer_id, 'updated' => false]);
     return Outlet::where('retailer_id', '=', $retailer_id)->get();
 }
 function __construct()
 {
     Outlet::init(array('connection' => array('type' => 'datamanager'), 'classes' => array()));
     $this->outlet =& Outlet::getInstance();
 }
Exemple #28
0
<?php

set_include_path(realpath(dirname(__FILE__) . '/../../../classes') . ';' . get_include_path());
require_once 'outlet/Outlet.php';
Outlet::addConfig(include 'outlet-config.php');
 /**
  * Execute the query
  * @return array result set
  */
 function find()
 {
     $outlet = $this->outlet;
     // get the 'from'
     $tmp = explode(' ', $this->from);
     $from = $tmp[0];
     $from_aliased = count($tmp) > 1 ? $tmp[1] : $tmp[0];
     $config = $this->outlet->getConfig();
     $entity_config = $config->getEntity($from);
     $props = $entity_config->getProperties();
     $from_props = $props;
     $select_cols = array();
     foreach ($props as $key => $p) {
         $select_cols[] = "\n{" . $from_aliased . '.' . $key . '} as ' . $from_aliased . '_' . $key;
     }
     // get the include entities
     $with = array();
     $with_aliased = array();
     $join_q = '';
     foreach ($this->with as $with_key => $j) {
         $tmp = explode(' ', $j);
         $with[$with_key] = $tmp[0];
         $with_aliased[$with_key] = count($tmp) > 1 ? $tmp[1] : $tmp[0];
         $assoc = $entity_config->getAssociation($with[$with_key]);
         if (!$assoc) {
             throw new OutletException('No association found with entity or alias [' . $with[$with_key] . ']');
         }
         $props = $config->getEntity($assoc->getForeign())->getProperties();
         foreach ($props as $key => $p) {
             $select_cols[] = "\n{" . $with_aliased[$with_key] . '.' . $key . '} as ' . $with_aliased[$with_key] . '_' . $key;
         }
         $aliased_join = $with_aliased[$with_key];
         $join_q .= "LEFT JOIN {" . $assoc->getForeign() . " " . $aliased_join . "} ON {" . $from_aliased . '.' . $assoc->getKey() . "} = {" . $with_aliased[$with_key] . '.' . $assoc->getRefKey() . "} \n";
     }
     $q = "SELECT " . implode(', ', $select_cols) . " \n";
     if ($this->select) {
         $q .= ", " . $this->select;
     }
     $q .= " FROM {" . $this->from . "} \n";
     $q .= $join_q;
     $q .= implode("\n", $this->joins);
     if ($this->query) {
         $q .= 'WHERE ' . $this->query . "\n";
     }
     if ($this->groupBy) {
         $q .= 'GROUP BY ' . $this->groupBy . "\n";
     }
     if ($this->orderby) {
         $q .= 'ORDER BY ' . $this->orderby . "\n";
     }
     if ($this->having) {
         $q .= 'HAVING ' . $this->having . "\n";
     }
     // TODO: Make it work on MS SQL
     //	   In SQL Server 2005 http://www.singingeels.com/Articles/Pagination_In_SQL_Server_2005.aspx
     if ($this->limit) {
         $q .= 'LIMIT ' . $this->limit;
         if ($this->offset) {
             $q .= ' OFFSET ' . $this->offset;
         }
     }
     $stmt = $outlet->query($q, $this->params);
     $res = array();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $data = array();
         // Postgres returns columns as lowercase
         // TODO: Maybe everything should be converted to lower in query creation / processing to avoid this
         if ($outlet->getConnection()->getDialect() == 'pgsql') {
             foreach ($from_props as $key => $p) {
                 $data[$p[0]] = $row[strtolower($from_aliased) . '_' . strtolower($key)];
             }
         } else {
             foreach ($from_props as $key => $p) {
                 $data[$p[0]] = $row[$from_aliased . '_' . $key];
             }
         }
         $obj = $outlet->getEntityForRow($entity_config, $data);
         foreach ($with as $with_key => $w) {
             $a = $entity_config->getAssociation($w);
             if ($a) {
                 $data = array();
                 $setter = $a->getSetter();
                 $foreign = $a->getForeign();
                 $with_entity = $config->getEntity($foreign);
                 if ($a instanceof OutletOneToManyConfig) {
                     // TODO: Implement...
                 } elseif ($a instanceof OutletManyToManyConfig) {
                     // TODO: Implement...
                 } else {
                     // Postgres returns columns as lowercase
                     // TODO: Maybe everything should be converted to lower in query creation / processing to avoid this
                     if ($outlet->getConnection()->getDialect() == 'pgsql') {
                         foreach ($with_entity->getProperties() as $key => $p) {
                             $data[$p[0]] = $row[strtolower($with_aliased[$with_key] . '_' . $key)];
                         }
                     } else {
                         foreach ($with_entity->getProperties() as $key => $p) {
                             $data[$p[0]] = $row[$with_aliased[$with_key] . '_' . $key];
                         }
                     }
                     $f = $with_entity->getPkColumns();
                     // check to see if we found any data for the related entity
                     // using the pk
                     $data_returned = false;
                     $pk_values = array();
                     foreach ($f as $k) {
                         if (isset($data[$k])) {
                             $data_returned = true;
                             break;
                         }
                     }
                     // only fill object if there was data returned
                     if ($data_returned) {
                         $obj->{$setter}($outlet->getEntityForRow($with_entity, $data));
                     }
                 }
             }
         }
         $res[] = $obj;
     }
     return $res;
 }
 /**
  * Show the form for editing the specified outlet.
  *
  * @param  int  $id
  * @return Response
  */
 public function editService($service)
 {
     $title = 'Edit Service';
     $outlets = Outlet::lists('name', 'id');
     $images = Picture::getByRefId($service->id, 'service');
     return View::make('admin.services.edit', compact('service', 'outlets', 'title'))->nest('imageForm', 'site.partials.image.create', ['refId' => $service->id, 'type' => 'service', 'images' => $images]);
     // return View::make('admin.services.edit', compact('service', 'title', 'outlets' ));
 }