public function index() { $this->language->load('common/update'); $data = $this->language->all(); $this->document->setTitle($data['heading_title']); if (!$this->validate('access')) { exit; } if (isset($this->session->data['msg_success'])) { $data['text_success'] = $this->session->data['msg_success']; unset($this->session->data['msg_success']); } if (isset($this->session->data['msg_error'])) { $data['text_error'] = $this->session->data['msg_error']; unset($this->session->data['msg_error']); } if (!extension_loaded('xml')) { $data['text_error'] = $this->language->get('error_xml'); } if (!extension_loaded('zip')) { $data['text_error'] = $this->language->get('error_zip'); } $data['token'] = $this->session->data['token']; $data['check'] = $this->url->link('common/update/check', 'token=' . $this->session->data['token'], 'SSL'); $data['update'] = $this->url->link('common/update/update', 'token=' . $this->session->data['token'], 'SSL'); $data['changelog'] = $this->url->link('common/update/changelog', 'token=' . $this->session->data['token'], 'SSL'); $addon = new Addon($this->registry); $data['addons'] = $addon->getAddons(); $data['updates'] = $this->update->getUpdates(); $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); $this->response->setOutput($this->load->view('common/update.tpl', $data)); }
public function init() { $value = $this->getValue(); if ($this->_riseValue === null) { $addonModel = new Addon(); $addonRow = $addonModel->getBrandAddon($this->addonTypeId, $this->customerTypeId, $this->brandId); $this->_riseValue = $addonRow->interest_value / 100; } $value += $this->_riseValue; $this->setValue($value); }
function __construct($admin_path) { $this->check_magic_quotes(); require $admin_path . '/core/library/config.php'; $config = $this->config = new Config($admin_path); require $config->library_path . '/string.php'; require $config->library_path . '/file.php'; spl_autoload_register(array($this, 'autoload')); $is_config_loaded = $this->config->load(); $this->setup_error_reporting(); if (!$is_config_loaded) { $router = new Router($config, null, '/setup/install/'); } else { $router = new Router($config); } $hook = new Hook(); $admin_script = new Admin\Scripts($router->admin_url, $router, $config); $admin_style = new Admin\Styles($router->admin_url, $router, $config); $hook->add('admin_head', array($admin_style, 'do_items'), 0, 10); $hook->add('admin_head', array($admin_script, 'do_head_items'), 0, 10); $hook->add('admin_footer', array($admin_script, 'do_footer_items'), 0, 100); $settings = new Settings($config); $router->settings = $settings; $active_template = $settings->get_template_about(); $template_script = new Template\Scripts('', $router, $config, $active_template['version']); $template_style = new Template\Styles('', $router, $config, $active_template['version']); $hook->add('head', array($template_style, 'do_items'), 0, 10); $hook->add('head', array($template_script, 'do_head_items'), 0, 10); $hook->add('footer', array($template_script, 'do_footer_items'), 0, 100); $user = new User($config, $router); $view = new View($config, $router, $hook); if ($settings->get('connection', 'type') && 'direct' != $settings->get('connection', 'type')) { $class_name = Filesystem::get_class_name($settings->get('connection', 'type')); $filesystem = new $class_name($config, array('connection_type' => $settings->get('connection', 'type'), 'hostname' => $settings->get('connection', 'hostname'), 'username' => $settings->get('connection', 'username'), 'password' => $settings->get('connection', 'password'))); } else { $filesystem = new Filesystem\Direct($config); } $addon = new Addon($config, $settings, $hook, $admin_script, $admin_style, $template_script, $template_style, $filesystem, $router); $addon->load_active(); $content = new Content($config, $filesystem, $router, $settings, $hook); $template = new Template($config, $filesystem, $router, $settings, $hook, $template_script, $template_style, $content); $router->parse_request_url(); $router->set_controller_class(); $controller_class = $router->controller_class; $controller = new $controller_class($router, $view, $filesystem, $config, $user, $template, $settings, $hook, $content, $addon); if (!$user->is_logged_in() && !$controller->is_no_auth_action()) { Router::redirect($router->admin_url('/user/login/')); exit; } $controller->call_action(); }
public function getTable($customerType, $addonType, $version = null) { $tableData = new stdClass(); $tableData->header = array(''); $tableData->data = array(); $addonTypeModel = new AddonType(); $addonTypeRow = $addonTypeModel->findOne($addonType); $addonTypeCode = $addonTypeRow->code; $branchModel = new Branch(); $branches = $branchModel->fetchAll(); foreach ($branches as $branch) { $tableData->header[] = $branch->branch_name; } $addon = new Addon(); $addonResults = $addon->getOrderedAddons($customerType, $addonType, $version); $previousStep = null; $rowArray = array(); foreach ($addonResults as $addonResult) { if ($addonResult->step_description !== $previousStep) { if ($previousStep !== null) { $tableData->data[] = $rowArray; } $previousStep = $addonResult->step_description; switch ($addonTypeCode) { case 'deposit_period': $rowArray = array($previousStep); break; case 'deposit_amount': case 'customer_engagement': $rowArray = array(number_format($previousStep, 0, '.', ' ')); break; case 'new_old_money': if ($previousStep == 0) { $rowArray = array('Stare środki'); } else { $rowArray = array('Nowe środki'); } break; case 'brand': $rowArray = array('Dodatek'); break; } } $rowArray[] = $addonResult->interest_value; } $tableData->data[] = $rowArray; return $tableData; }
public function perform() { $package = Addon::get()->byID($this->args['id']); $builder = Injector::inst()->get('AddonBuilder'); $builder->build($package); $package->BuildQueued = false; $package->write(); }
/** * @param string * @return string|NULL */ public function filterOut($vendor) { $row = $this->addons->findByComposerVendor($vendor)->limit(1)->fetch(); if (!$row) { return NULL; } $addon = Addon::fromActiveRow($row); return $addon->composerVendor; }
public function postCreate() { $validator = Validator::make(Input::all(), Addon::$rules); if ($validator->passes()) { $addon = new Addon(); $addon->type = Input::get('type'); $addon->description = Input::get('description'); $addon->price = Input::get('price'); $addon->vendor_id = Auth::user()->id; $image = Input::file('image'); $filename = date('Y-m-d-H:i:s') . "-" . $image->getClientOriginalName(); $path = public_path('img/addons/' . $filename); Image::make($image->getRealPath())->resize(468, 249)->save($path); $addon->image = 'img/addons/' . $filename; $addon->save(); return Redirect::to('admin/addons/index')->with('message', 'Addon created.'); } return Redirect::to('admin/addons/index')->with('message', 'Addon not created. Something went wrong.')->withErrors($validator)->withInput(); }
public function init() { $value = $this->getValue(); if ($this->_riseValue === null) { $addonModel = new Addon(); $rangeStart = $addonModel->getAddonAmountRangeStart($this->addonTypeId, $this->customerTypeId, $this->brandId, $this->depositAmount); $rangeEnd = $addonModel->getAddonAmountRangeEnd($this->addonTypeId, $this->customerTypeId, $this->brandId, $this->depositAmount); if ($rangeStart !== null && $rangeEnd === null) { $this->_riseValue += $rangeStart->interest_value / 100; } else { $x0 = $rangeStart->interest_step; $x1 = $rangeEnd->interest_step; $y0 = $rangeStart->interest_value; $y1 = $rangeEnd->interest_value; $x = $this->depositAmount; $this->_riseValue += $this->linearInterpolation($x0, $x1, $y0, $y1, $x) / 100; } } $value += $this->_riseValue; $this->setValue($value); }
public function run($request) { $addons = Addon::get(); if ($request->getVar('addons')) { $addons = $addons->filter('Name', explode(',', $request->getVar('addons'))); } foreach ($addons as $addon) { $this->log(sprintf('Building "%s"', $addon->Name)); try { $this->builder->build($addon); } catch (RuntimeException $e) { $this->log('Error: ' . $e->getMessage()); } $addon->BuildQueued = false; $addon->write(); } }
private function buildScreenshots(Addon $addon, PackageInterface $package, $path) { $extra = $package->getExtra(); $screenshots = array(); $target = self::SCREENSHOTS_DIR . '/' . $addon->Name; if (isset($extra['screenshots'])) { $screenshots = (array) $extra['screenshots']; } elseif (isset($extra['screenshot'])) { $screenshots = (array) $extra['screenshot']; } // Delete existing screenshots. foreach ($addon->Screenshots() as $screenshot) { $screenshot->delete(); } $addon->Screenshots()->removeAll(); foreach ($screenshots as $screenshot) { if (!is_string($screenshot)) { continue; } $scheme = parse_url($screenshot, PHP_URL_SCHEME); // Handle absolute image URLs. if ($scheme == 'http' || $scheme == 'https') { $temp = TEMP_FOLDER . '/' . md5($screenshot); if (!copy($screenshot, $temp)) { continue; } $data = array('name' => basename($screenshot), 'size' => filesize($temp), 'tmp_name' => $temp, 'error' => 0); } else { $source = $path . '/' . ltrim($screenshot, '/'); // Prevent directory traversal. if ($source != realpath($source)) { continue; } if (!file_exists($source)) { continue; } $data = array('name' => basename($source), 'size' => filesize($source), 'tmp_name' => $source, 'error' => 0); } $upload = new Upload(); $upload->setValidator(new AddonBuilderScreenshotValidator()); $upload->load($data, $target); if ($file = $upload->getFile()) { $addon->Screenshots()->add($file); } } }
public function run($request) { $dateOneWeekAgo = date('Y-m-d', strtotime('-1 week')); $addons = Addon::get()->filter('LastUpdated:LessThan', $dateOneWeekAgo); foreach ($addons as $addon) { try { $addon->Keywords()->removeAll(); $addon->Screenshots()->removeAll(); $addon->CompatibleVersions()->removeAll(); foreach ($addon->Versions() as $version) { $version->Authors()->removeAll(); $version->Keywords()->removeAll(); $version->CompatibleVersions()->removeAll(); $version->delete(); } $addon->delete(); } catch (Elastica\Exception\NotFoundException $e) { // no-op } } }
private function updateCompatibility(Addon $addon, AddonVersion $version, CompletePackage $package) { $require = null; if ($package->getRequire()) { foreach ($package->getRequire() as $name => $link) { if ((string) $link == 'self.version') { continue; } if ($name == 'silverstripe/framework') { $require = $link; break; } if ($name == 'silverstripe/cms') { $require = $link; } } } if (!$require) { return; } $addon->CompatibleVersions()->removeAll(); $version->CompatibleVersions()->removeAll(); foreach ($this->silverstripes as $id => $link) { try { $constraint = $this->versionParser->parseConstraints($require); if ($link->matches($constraint)) { $addon->CompatibleVersions()->add($id); $version->CompatibleVersions()->add($id); } } catch (Exception $e) { // An exception here shouldn't prevent further updates. Debug::log($addon->Name . "\t" . $addon->ID . "\t" . $e->getMessage()); } } }
/* |-------------------------------------------------------------------------- | The Template Parser |-------------------------------------------------------------------------- | | Statamic uses a *highly* modified fork of the Lex parser, created by | Dan Horrigan. Kudos Dan! | */ require_once __DIR__ . '/vendor/Lex/Parser.php'; /* |-------------------------------------------------------------------------- | Internal API & Class Autoloader |-------------------------------------------------------------------------- | | An autoloader for our internal API and other core classes | */ // helper functions require_once __DIR__ . '/core/exceptions.php'; require_once __DIR__ . '/core/functions.php'; // register the Statamic autoloader spl_autoload_register("autoload_statamic"); // attempt HTML caching // although this doesn't really have anything to do with autoloading, putting this // here allows us to not force people to update their index.php files if (Addon::getAPI('html_caching')->isEnabled() && Addon::getAPI('html_caching')->isPageCached()) { die(Addon::getAPI('html_caching')->getCachedPage()); } // mark milestone for debug panel Debug::markMilestone('autoloaders ready');
$template_list[] = "taxonomies"; $template_list[] = $type; $content_found = true; } // content was found if ($content_found) { // mark milestone for debug panel Debug::markMilestone('content found'); // protect if (is_array($data) && $data) { try { Addon::getAPI('protect')->hasAccess(URL::getCurrent()); } catch (Slim\Exception\Stop $e) { throw $e; } catch (Exception $e) { // something went wrong with protect, 404 this Log::error('The following error occurred while trying to protect `' . htmlspecialchars($data['current_url']) . '`: ' . $e->getMessage() . ' — for extra precaution, we sent this use the 404 page.', 'core', 'protect'); $content_found = false; $response_code = 404; } } // alter the response code if you want $response_code = (int) array_get($data, '_response', $response_code); // if the response_code was set to 404, show a 404 if ($response_code === 404) {
/** * Stop an addon and make it unavailable. * * @param Addon $addon The addon to stop. */ public function stopAddon(Addon $addon) { if (empty($addon)) { trigger_error("Null addon supplied to AddonManager->stopAddon().", E_USER_NOTICE); return; } unset($this->enabled[$addon->getType() . '/' . $addon->getKey()]); // Remove all of the addon's classes from the autoloader. foreach ($addon->getClasses() as $classKey => $row) { // list($class, $subpath) = $row; unset($this->autoloadClasses[$classKey]); // See if there is another class that can be registered in place. if (!empty($this->autoloadClassesBak[$classKey])) { foreach ($this->autoloadClassesBak[$classKey] as $i => $rowBak) { list($path, $addon) = $rowBak; /* @var Addon $maxAddon */ if (!isset($maxAddon) || $maxAddon->getPriority() < $addon->getPriority()) { $maxAddon = $addon; $maxIndex = $i; } } if (isset($maxIndex)) { $this->autoloadClasses[$classKey] = $this->autoloadClassesBak[$classKey][$maxIndex]; unset($this->autoloadClassesBak[$classKey][$maxIndex]); } } } }
<?php include '../../connection.php'; include '../class/addon.php'; if (isset($_GET['id'])) { $addon_id = $_GET['id']; if (Addon::AddonsDelete($addon_id)) { header('Location: manageroom.php'); } else { echo '<script type="text/javascript">'; echo 'alert("Error");'; echo 'window.location.href = "manageroom.php";'; echo '</script>'; } } //
echo page("admin", "members"); ?> "> <i class="icon"><img src="images/admin/members.png" width="16px"></i> Search users </a> </li> </ul> </li> <li class="item"><a href="#" class="menu" rel="admin_addons">Addons</a> <ul class="dropdown" id="admin_addons"> <li class="title"><a>Installed addons</a></li> <?php $addons = makefilelist(PATH_APPLICATIONS, ".|..|index.html", true, "folders"); if (count($addons) > 0) { foreach ($addons as $addon) { $add = new Addon($addon); if ($add->isInstalled() && $add->hasAdmin()) { ?> <li> <a href="<?php echo page("admin", "addons", "admin", $addon); ?> "> <i class="icon"><img src="images/admin/addons.png" width="16px"></i> <?php echo ucfirst($addon); ?> </a> </li> <?php } }
/** * Use a given $addon's API * * @param string $addon Name of the addon to use * @return boolean * @throws Exception */ public function api($addon) { return Addon::getAPI($addon); }
?> </td> <td class="border-bottom border-right" width="100px"></td> <td class="border-bottom border-right"><?php echo _t("Group"); ?> </td> <td class="border-bottom"><?php echo _t("Installed"); ?> </td> </tr> </thead> <?php foreach ($addons as $addon) { $app = new Addon($addon); if ($app->checkInstall()) { $db = new DB("addons"); $db->join("left", "{PREFIX}groups", "addon_group", "group_id"); $db->select("addon_name = '" . $db->escape($addon) . "'"); if ($db->numRows()) { $db->nextRecord(); $group = $db->group_name; $installed = get_date($db->addon_added); } else { $group = ""; $installed = ""; } ?> <tr> <td class="border-bottom"><?php
<?php $url = "../index.php?mod=addon&act=list"; require_once "../model/Addon.php"; $model = new Addon(); $addon_id = (int) $_POST['addon_id']; $addon_name = $model->processData($_POST['addon_name']); if ($addon_id > 0) { $model->updateAddon($addon_id, $addon_name); header('location:' . $url); } else { $model->insertAddon($addon_name); header('location:' . $url); }
/** * Returns a list of addons in the Addon class. */ public function getAddons($type = 'all') { // TODO: add support to grab addon options. $type = strtolower($type); $allowed_types = array('all', 'enabled', 'disabled'); if (!in_array($type, $allowed_types)) { $type = 'all'; } $installed_addons = $this->getModels()->getModel('addon')->getAllAddOns(); $addons = array(); foreach ($installed_addons as $addon) { $temp_addon = new Addon($addon); if ($type == 'enabled' && $temp_addon->isEnabled() || $type == 'disabled' && !$temp_addon->isEnabled() || $type == 'all') { $addons[] = $temp_addon; } } return $addons; }
/** * render * Finds and chooses the correct template, then renders the page * * @param string $template Template (or array of templates, in order of preference) to render the page with * @return string */ public function render($template) { $html = '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">No template found.</p>'; $list = $template ? $list = array($template) : self::$_templates; $template_type = 'html'; // Allow setting where to get the template from if (!self::$_template_location) { self::$_template_location = Path::assemble(BASE_PATH, Config::getTemplatesPath(), 'templates'); } foreach ($list as $template) { $template_path = Path::assemble(self::$_template_location, $template); $override_path = Path::assemble(BASE_PATH, Config::getThemesPath(), Config::getTheme(), 'admin', $template); if (File::exists($template_path . '.html') || file_exists($template_path . '.php')) { // set debug information Debug::setValue('template', $template); Debug::setvalue('layout', str_replace('layouts/', '', self::$_layout)); Debug::setValue('statamic_version', STATAMIC_VERSION); Debug::setValue('php_version', phpversion()); Debug::setValue('theme', array_get($this->data, '_theme', null)); Debug::setValue('environment', array_get($this->data, 'environment', '(none)')); $this->data['_debug'] = array('template' => Debug::getValue('template'), 'layout' => Debug::getValue('layout'), 'version' => Debug::getValue('statamic_version'), 'statamic_version' => Debug::getValue('statamic_version'), 'php_version' => Debug::getValue('php_version'), 'theme' => Debug::getValue('theme'), 'environment' => Debug::getValue('environment')); # standard lex-parsed template if (File::exists($template_path . '.html')) { $template_type = 'html'; $this->appendNewData($this->data); // Fetch template and parse any front matter $template = Parse::frontMatter(File::get($template_path . '.html')); self::$_extra_data = $template['data'] + self::$_extra_data; $this->prependNewData(self::$_extra_data); $html = Parse::template($template['content'], Statamic_View::$_dataStore, array($this, 'callback')); break; # lets forge into raw data } elseif (File::exists($override_path . '.php') || File::exists($template_path . '.php')) { $template_type = 'php'; extract($this->data); ob_start(); if (File::exists($override_path . '.php')) { $template_path = $override_path; } require $template_path . ".php"; $html = ob_get_clean(); break; } else { Log::error("Template does not exist: '{$template_path}'", 'core'); } } } // mark milestone for debug panel Debug::markMilestone('template rendered'); // get rendered HTML $rendered = $this->_render_layout($html, $template_type); // mark milestone for debug panel Debug::markMilestone('layout rendered'); // store it into the HTML cache if needed if (Addon::getAPI('html_caching')->isEnabled()) { Addon::getAPI('html_caching')->putCachedPage($rendered); } // return rendered HTML return $rendered; }
/** * Get ALL the info about an addon, you will need addon id */ function addonInfo() { global $url_params; if (isset($url_params['id'])) { $addon = new Addon(); $addon_data = $addon->getAddonData($url_params['id']); printJson(json_encode($addon_data)); } }
<?php include '../../connection.php'; include '../class/addon.php'; if (isset($_GET['commentid'])) { $comment_ID = $_GET['commentid']; if (Addon::commentDelete($comment_ID)) { header('Location: comments.php'); } else { echo '<script type="text/javascript">'; echo 'alert("Error");'; echo 'window.location.href = "comments.php";'; echo '</script>'; } } //
public function api() { $json = array(); $this->load->language('extension/marketplace'); $this->document->setTitle($this->language->get('heading_title')); if ($this->validate()) { if (isset($this->session->data['cookie']) && isset($this->request->get['api'])) { // Include any URL parameters $url_data = array(); foreach ($this->request->get as $key => $value) { if ($key != 'route' && $key != 'token' && $key != 'store_id' && $key != 'api') { $url_data[$key] = $value; } } if (isset($this->request->get['store']) and !empty($this->request->get['store'])) { $this->apiBaseUrl = str_replace(parse_url($this->apiBaseUrl, PHP_URL_HOST), $this->request->get['store'] . '.' . parse_url($this->apiBaseUrl, PHP_URL_HOST), $this->apiBaseUrl); } $addon_lib = new Addon($this->registry); $addons = $addon_lib->getAddons(); foreach ($addons as $addon) { $data[$addon['product_id']] = $addon['product_version']; } if (isset($data)) { $this->request->post['addons'] = $data; } $curl = curl_init(); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLINFO_HEADER_OUT, true); curl_setopt($curl, CURLOPT_USERAGENT, $this->request->server['HTTP_USER_AGENT']); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_FORBID_REUSE, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_URL, $this->apiBaseUrl . 'index.php?route=' . $this->request->get['api'] . ($url_data ? '&' . http_build_query($url_data) : '')); if ($this->request->post) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->request->post)); } curl_setopt($curl, CURLOPT_COOKIE, session_name() . '=' . $this->session->data['cookie'] . ';'); $json = curl_exec($curl); curl_close($curl); } } else { $response = array(); $response['error']['warning'] = $this->error; unset($this->error); $json = json_encode($response); } if (!empty($this->request->server['HTTP_X_REQUESTED_WITH'])) { $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput($json); } else { $this->response->addHeader('Content-Type: text/plain'); $this->response->setOutput($json); } }
<?php include '../Class/Addon.php'; include "../../connection.php"; $item = $_POST['item']; $price = $_POST['price']; $quantity = $_POST['quantity']; if ($item == '') { echo 'Item is required'; } else { if ($price == '') { echo 'Price is required'; } else { if ($quantity == '') { echo 'Quantity is required'; } else { $Addon = new Addon($item, $price, $quantity); if ($Addon->Addon()) { echo "true"; } } } }
<?php include '../class/addon.php'; include "../../connection.php"; $addItem = $_GET['additem']; $addPrice = $_GET['addprice']; $addQuantity = $_GET['addquantity']; $addID = $_GET['addID']; if ($addItem == '' || $addPrice == '' || $addQuantity == '') { echo "<script>\n alert('Add On textbox is empty');\n window.location='manageroom.php';\n </script>"; } else { /*$Addon= new Addon($addItem,$addPrice,$addQuantity); if ($Addon->addonUpdate()) { echo "success"; } else { echo "An error has occured during the operation", "Wesviewhotel"; } }*/ if (Addon::addonUpdate($addItem, $addPrice, $addQuantity, $addID)) { echo "<script>\n alert('Addon Succesfully updated');\n window.location='manageroom.php';\n </script>"; } }
* Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @link http://opentracker.nu openTracker Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @author Wuild * @package openTracker */ if (!defined("INCLUDED")) { die("Access denied"); } try { if (!$this->addon) { throw new Exception("missing data"); } $addon = new Addon($this->addon); if (!$addon->checkInstall()) { throw new Exception("addons is not installable"); } if (isset($_POST['save'])) { try { if ($_POST['secure_input'] != $_SESSION['secure_token']) { throw new Exception("Wrong secured token"); } $addon->Install(); $db = new DB("addons"); $db->setColPrefix("addon_"); $db->installed = true; $db->group = $_POST['group']; $db->update("addon_name = '" . $db->escape($this->addon) . "'"); header("location: " . page("admin", "addons"), true);
public function getView($order_id) { $order = Order::where('order_id', '=', $order_id)->get()->toArray(); // $order_master = Ordermaster::where('order_id','=',$order_id)->get()->toArray(); if ($order[0]['type'] == "cake") { $prod_details = Cakes::where('id', '=', $order[0]['product_id'])->get(array('image', 'title', 'description'))->toArray(); } else { $prod_details = Product::where('id', '=', $order[0]['product_id'])->get(array('image', 'title', 'description'))->toArray(); } $order_addon_id = $order[0]['add_on_id']; $addon_det = array(); if ($order_addon_id != "") { $order_addons = explode(',', $order_addon_id); foreach ($order_addons as $k => $v) { $temp = Addon::find($v)->toArray(); array_push($addon_det, $temp); } } $order[0]['prod_details'] = $prod_details[0]; // $order[0]['master_details'] = $order_master[0]; return View::make('orders.view')->with('order', $order[0])->with('addon_det', $addon_det); }
public function RandomAddons($limit = 10) { return Addon::get()->sort(DB::getConn()->random(), 'DESC')->limit($limit); }