Example #1
0
 /**
  * Get the layout from the database
  * 
  * @param string $layout_id
  * @param bool $mobile
  *
  * @return array
  */
 private function getLayoutFromDatabase($layout_id, $is_mobile = false)
 {
     $device = $is_mobile ? 'mobile' : 'desktop';
     $layout_table = $this->model->getTable($device . '_layouts');
     $templates_table = $this->model->getTable('templates');
     $key = md5($this->model->cacheKey . '_' . __METHOD__ . '_' . $layout_id . '_' . $device);
     if (!App::environment('local') && Cache::has($key)) {
         $return = $this->model->populate_results(array('json_views' => Cache::get($key)), 'LayoutFromFile', true);
     } else {
         $layout = DB::table($layout_table)->join($templates_table, $templates_table . '.id', '=', $layout_table . '.template')->where($layout_table . '.id', '=', $layout_id)->where($templates_table . '.active', '>', '0')->select($layout_table . '.*', $templates_table . '.name as template')->first();
         if (!App::environment('local')) {
             Cache::put($key, $layout, $this->model->cacheSec / 60);
         }
     }
     return $this->model->populate_results($layout, 'Layout');
 }