Example #1
0
 public function setData()
 {
     $current_page = $this->getPage(URL::current());
     if (Input::all()) {
         session()->put("{$this->prefix}.data." . $current_page['alias'], Input::all());
     }
 }
 public function checkForUpdate($gamertag = '')
 {
     if ($this->request->ajax() && !\Agent::isRobot()) {
         try {
             $account = Account::with('destiny.characters')->where('seo', Text::seoGamertag($gamertag))->firstOrFail();
             // We don't care about non-panda members
             if (!$account->isPandaLove()) {
                 $this->inactiveCounter = 1;
             }
             // check for 10 inactive checks
             if ($account->destiny->inactiveCounter >= $this->inactiveCounter) {
                 return response()->json(['updated' => false, 'frozen' => true, 'last_update' => 'This account hasn\'t had new data in awhile. - <a href="' . URL::action('Destiny\\ProfileController@manualUpdate', [$account->seo]) . '" class="ui  horizontal green label no_underline">Update Manually</a>']);
             }
             $char = $account->destiny->firstCharacter();
             if ($char->updated_at->diffInMinutes() >= $this->refreshRateInMinutes) {
                 // update this
                 $this->dispatch(new UpdateAccount($account));
                 return response()->json(['updated' => true, 'frozen' => false, 'last_update' => $char->getLastUpdatedRelative()]);
             }
             return response()->json(['updated' => false, 'frozen' => false, 'last_update' => $char->getLastUpdatedRelative()]);
         } catch (ModelNotFoundException $e) {
             return response()->json(['error' => 'Gamertag not found']);
         }
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $item = static::queryAll()->withTrashed()->find($id);
     $this->fireCMSControllerEvent('showing', [$item, $id]);
     $panels = $this->_show($item);
     $this->layout->content = View::make('laravel-cms::cms/panels')->with('panels', $panels);
     $url = \HTMLize::create($item)->url();
     if ('javascript:;' != $url && $url) {
         $shortcut = new \stdClass();
         $shortcut->url = $url;
         $shortcut->title = '网页中查看';
         $this->layout->shortcuts[] = $shortcut;
     }
     try {
         $url = URL::action(static::$action . '.edit.form', [$id]);
     } catch (\InvalidArgumentException $e) {
         $url = null;
     }
     if ($url) {
         $shortcut = new \stdClass();
         $shortcut->url = $url;
         $shortcut->title = '打开编辑';
         $this->layout->shortcuts[] = $shortcut;
     }
     $this->layout->title = static::$name . '详情';
 }
Example #4
0
 private function loadPageTitle()
 {
     $pageTitles = config('forone.nav_titles');
     $curRouteName = Route::currentRouteName();
     if (array_key_exists($curRouteName, $pageTitles)) {
         return $pageTitles[$curRouteName];
     } else {
         // load menus title
         $url = URL::current();
         $menus = config('forone.menus');
         foreach ($menus as $title => $menu) {
             if (array_key_exists('children', $menu) && $menu['children']) {
                 foreach ($menu['children'] as $childTitle => $child) {
                     $pageTitle = $this->parseTitle($childTitle, $url, $child['active_uri']);
                     if ($pageTitle) {
                         return $pageTitle;
                     }
                 }
             } else {
                 $pageTitle = $this->parseTitle($title, $url, $menu['active_uri']);
                 if ($pageTitle) {
                     return $pageTitle;
                 }
             }
         }
     }
     return $curRouteName;
 }
 /**
  * GET DISTANCE BETWEEN LOCATION AND CAFES
  * @param $lat1
  * @param $lon1
  * @param $lat2
  * @param $lon2
  * @param $unit
  * @param $limit
  * @param $id
  * @return array|bool
  */
 public function distance($lat1, $lon1, $lat2, $lon2, $unit, $limit, $id)
 {
     $theta = $lon1 - $lon2;
     $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
     $dist = acos($dist);
     $dist = rad2deg($dist);
     $miles = $dist * 60 * 1.1515;
     $unit = strtoupper($unit);
     //$miles = round($miles);
     $location = $this->cafe->find($id);
     $phone = $location->phone ? '<br/>' . $location->phone : null;
     if (strlen($location->image) < 1) {
         $image = URL::asset('library/img/loc-noimg.jpg');
     } else {
         $image = URL::asset('uploads/store_images/' . $location->image);
     }
     $array = array();
     if ($miles <= $limit) {
         array_push($array, ['image' => $image, 'miles' => intval($miles), 'id' => $location->id, 'name' => $location->name, 'address' => $location->address . '<br/>' . $location->city . ', ' . $location->state . ' ' . $location->zip_code . $phone, 'lat' => $location->lat, 'lng' => $location->lng, 'state' => $location->state, 'country' => $location->country, 'bakery' => $location->bakery, 'icecream' => $location->icecream, 'coffee' => $location->coffee, 'frozenyogurt' => $location->frozenyogurt, 'smoothies' => $location->smoothies, 'wifi' => $location->wifi, 'curbside' => $location->curbside, 'cookie' => $location->cookie, 'savory' => $location->savory, 'map' => $location->maps_url, 'facebook' => $location->facebook_url, 'online_order' => $location->online_order, 'coming_soon' => $location->coming_soon]);
         return $array;
     }
     return false;
     //return $miles;
     //        if ($unit == "K") {
     //            return ($miles * 1.609344);
     //        } else if ($unit == "N") {
     //            return ($miles * 0.8684);
     //        } else {
     //            return round($miles). ' Miles';
     //        }
 }
 protected function imageAvatar()
 {
     $path = 'upload/' . date('Ym/d/');
     $filename = KRandom::getRandStr() . '.jpg';
     if (!File::exists(public_path($path))) {
         File::makeDirectory(public_path($path), 493, true);
     }
     while (File::exists(public_path($path) . $filename)) {
         $filename = KRandom::getRandStr() . '.jpg';
     }
     $this->image->resize(new \Imagine\Image\Box(300, 300))->save(public_path($path) . $filename);
     ImageModel::createUploadedImage($path . $filename, URL::asset($path . $filename));
     $user = AuthModel::user();
     $url = URL::asset($path . $filename);
     if ($user) {
         if ($user->profile) {
             $user->profile->avatar = $url;
             $user->profile->save();
         } else {
             ProfileModel::create(array('user_id' => $user->id, 'avatar' => $url));
         }
     } else {
     }
     return $url;
 }
Example #7
0
 function __construct()
 {
     if (false == self::$enabled) {
         return redirect(URL::to('/'), 302)->send();
     }
     Commons::init();
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (Auth::check()) {
         return new RedirectResponse(URL::route('home'));
     }
     return $next($request);
 }
Example #9
0
 public function rollback($entity, $id)
 {
     $modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity);
     if (!class_exists($modelString)) {
         $modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity) . 's';
     }
     if (!class_exists($modelString)) {
         $modelString = 'Quarx\\Modules\\' . ucfirst(str_plural($entity)) . '.\\Models\\' . ucfirst(str_plural($entity));
     }
     if (!class_exists($modelString)) {
         $modelString = 'Quarx\\Modules\\' . ucfirst(str_plural($entity)) . '\\Models\\' . ucfirst(str_singular($entity));
     }
     if (!class_exists($modelString)) {
         $modelString = 'Quarx\\Modules\\' . ucfirst(str_singular($entity)) . '\\Models\\' . ucfirst(str_singular($entity));
     }
     if (!class_exists($modelString)) {
         Quarx::notification('Could not rollback Model not found', 'warning');
         return redirect(URL::previous());
     }
     $model = new $modelString();
     $modelInstance = $model->find($id);
     $archive = Archive::where('entity_id', $id)->where('entity_type', $modelString)->limit(1)->offset(1)->orderBy('id', 'desc')->first();
     if (!$archive) {
         Quarx::notification('Could not rollback', 'warning');
         return redirect(URL::previous());
     }
     $archiveData = (array) json_decode($archive->entity_data);
     $modelInstance->fill($archiveData);
     $modelInstance->save();
     Quarx::notification('Rollback was successful', 'success');
     return redirect(URL::previous());
 }
Example #10
0
 public function latest()
 {
     if ($this->isLoggedIn && $this->request->has('personal') && $this->request->get('personal') == 'true') {
         $isCached = false;
         $bans = $this->repository->getPersonalBans($this->user->settings()->playerIds());
     } else {
         $isCached = Cache::has('bans.latest');
         $bans = $this->repository->getLatestBans();
     }
     if ($this->request->has('type') && $this->request->get('type') == 'rss') {
         $feed = Feed::make();
         $feed->title = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title'));
         $feed->description = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title'));
         $feed->setDateFormat('datetime');
         $feed->link = URL::to('api/bans/latest?type=rss');
         $feed->lang = 'en';
         foreach ($bans as $ban) {
             $title = sprintf('%s banned for %s', $ban['player']['SoldierName'], $ban['record']['record_message']);
             $view = View::make('system.rss.ban_entry_content', ['playerId' => $ban['player']['PlayerID'], 'playerName' => $ban['player']['SoldierName'], 'banreason' => $ban['record']['record_message'], 'sourceName' => $ban['record']['source_name'], 'sourceId' => $ban['record']['source_id'], 'banReason' => $ban['record']['record_message']]);
             $feed->add($title, $ban['record']['source_name'], $ban['player']['profile_url'], $ban['ban_startTime'], $title, $view->render());
         }
         return $feed->render('atom');
     }
     return MainHelper::response(['cols' => Lang::get('dashboard.bans.columns'), 'bans' => $bans], null, null, null, $isCached, true);
 }
 public function postRegister()
 {
     $request = Request::instance();
     $request->setTrustedProxies(array('192.0.0.1', '10.0.0.0/8', '127.0.0.1'));
     if ($request->has("email")) {
         $requestData = $request->all();
         $rules = array("email" => "required|max:255|email");
         $validator = Validator::make($requestData, $rules);
         if ($validator->fails()) {
             return redirect("/")->withErrors(array("Dit is geen correct e-mail adres."));
         } else {
             $email = $request->input("email");
             $verificationCode = md5(uniqid(rand(), true));
             DB::table("contestants")->insert(array("email" => $email, "verification_code" => $verificationCode, "verification_received" => false, "ip_address" => $request->getClientIp()));
             $url = URL::action("HomeController@handleVerification", array("verify" => $verificationCode, "email" => $email));
             $emailData = array("url" => $url);
             Mail::send("email.email", $emailData, function ($message) use($email) {
                 $message->from("*****@*****.**", "Laravel Contest");
                 $message->subject("Deelname wedstrijd!");
                 $message->to($email);
             });
             $data = array("email" => $email);
             return view("register.success", $data);
         }
         //Captcha
     }
     return redirect()->action("HomeController@getRegister");
 }
 public function testGetSourceSetAttribute()
 {
     $srcset = $this->createSourceSet();
     $base = URL::to('/');
     $expected = "{$base}/path.jpg 200w, {$base}/path2.jpg 300w";
     $this->assertEquals($expected, $srcset->getSrcSetAttribute());
 }
Example #13
0
 public function create($modelName, $item = null, ModelConfig $config = null)
 {
     $page = new Page();
     $header = new PageHeader();
     $header->setText('Create ' . $modelName);
     if ($item != null && isset($item->id)) {
         $model = $this->aujaConfigurator->getModel($modelName);
         $displayField = $this->aujaConfigurator->getDisplayField($model, $config);
         $header->setText('Edit ' . (isset($item->{$displayField}) ? $item->{$displayField} : $modelName));
         $deleteButton = new Button();
         $deleteButton->setText(Lang::trans('Delete'));
         $deleteButton->setConfirmationMessage(Lang::trans('Are you sure?'));
         $deleteButton->setTarget(URL::route($this->aujaRouter->getDeleteName($modelName), $item->id));
         $deleteButton->setMethod('delete');
         $header->addButton($deleteButton);
     }
     $page->addPageComponent($header);
     $form = new Form();
     $action = $item == null || !isset($item->id) ? URL::route($this->aujaRouter->getStoreName($modelName)) : URL::route($this->aujaRouter->getUpdateName($modelName), $item->id);
     $form->setAction($action);
     $form->setMethod($item == null ? 'POST' : 'PUT');
     $model = $this->aujaConfigurator->getModel($modelName);
     $visibleFields = $this->aujaConfigurator->getVisibleFields($model, $config);
     foreach ($visibleFields as $columnName) {
         $column = $model->getColumn($columnName);
         $formItem = $this->formItemFactory->getFormItem($model, $column, $item);
         $form->addFormItem($formItem);
     }
     $submit = new SubmitFormItem();
     $submit->setText(Lang::trans('Submit'));
     $form->addFormItem($submit);
     $page->addPageComponent($form);
     return $page;
 }
Example #14
0
 public function formatModel($model)
 {
     $script_url = str_replace(['http://', 'https://'], ['', ''], URL::to('/')) . '/zl.js';
     $model->form_code = '<form class="zlform" action="' . URL::action('\\Zephia\\ZLeader\\Http\\Controllers\\Api\\LeadController@store', ['slug' => $model->slug]) . '" method="post">' . "\r\n<!-- Fields: (zlfield_example) -->\r\n" . '</form>' . "\r\n";
     $model->form_code .= "<script type=\"text/javascript\">" . "\r\n" . "(function(d,s,e,t){e=d.createElement(s);e.type='text/java'+s;e.async='async';" . "\r\n" . "e.src='http'+('https:'===location.protocol?'s://':'://')+'" . $script_url . "';t=d.getElementsByTagName(s)[0];" . "\r\n" . "t.parentNode.insertBefore(e,t);})(document,'script');" . "\r\n" . "</script>";
     return $model;
 }
Example #15
0
 public function product($id)
 {
     // Product Detail
     $product = Product::find($id);
     $producer = Producer::find($product->producer);
     $producerItem = "<a href='" . URL::to('/') . "/producer/" . $producer->id . "/" . strtolower($producer->producer) . ".html'>" . $producer->producer . "</a>";
     // Category
     $productCategoryID = Product::find($id)->category_id;
     // breadcrumb
     $breadcrumb = $this->breadcrumb($productCategoryID, $id);
     // Best Seller
     $bestSeller = $this->bestSeller();
     $image = Images::where('productID', $product['id'])->first();
     $thumbnail = $image['imageSrc'];
     $thumbnailImage = '<a class="preView" rel="' . URL::to('/') . '/' . $thumbnail . '"><img src="' . URL::to('/') . '/' . $thumbnail . '" alt="" class="img-responsive"></a>';
     $images = Images::where('productID', $id)->get();
     $listImages = "";
     foreach ($images as $image) {
         $img = $image['imageSrc'];
         $listImages .= '<a href="' . URL::to('/') . '/' . $img . '" class="fancybox-button" rel="photos-lib"><img alt="Berry Lace Dress" src="' . URL::to('/') . '/' . $img . '"></a>';
     }
     $review = '<div class="fb-comments" data-href="' . URL::to('/') . '/product/' . $id . '"
             data-num-posts="10" data-width="700px"></div>';
     return view('home.product.detail')->with(['breadcrumb' => $breadcrumb, 'product' => $product, 'producer' => $producerItem, 'bestSeller' => $bestSeller, 'thumbnailImage' => $thumbnailImage, 'listImages' => $listImages, 'review' => $review]);
 }
Example #16
0
    /**
     * 启用禁用状态切换
     * @param $item
     * @return string
     */
    public static function block_btn_status_select($item)
    {
        $url = URL::action(static::$action . '.edit.status');
        if (Permission::checkMe(static::$action . '.edit.status')) {
            $disabled = "";
        } else {
            $disabled = "disabled";
        }
        $current = $item->getStatus();
        $token = Session::token();
        $li = '';
        $allowedStatus = $item->getAvailableNextStatus();
        if (isset(static::$allowedStatus) && is_array(static::$allowedStatus)) {
            $allowedStatus = array_intersect($allowedStatus, static::$allowedStatus);
        }
        foreach ($allowedStatus as $status) {
            $li .= <<<LI
<li><a class="table-role-btn-switch" href="javascript:;" data-attr-id='{$item->id}' data-attr-token='{$token}' data-attr-url='{$url}' {$disabled}>{$status}</a></li>
LI;
        }
        $button = <<<BUTTON
<div class="btn-group" style="margin:0 auto;">
      <button type="button" class="btn btn-xs btn-warning btn-current-status" {$disabled}>{$current}</button>
      <button type="button" class="btn btn-xs btn-warning dropdown-toggle" data-toggle="dropdown" {$disabled}>
        <span class="caret"></span>
        <span class="sr-only">Toggle Dropdown</span>
      </button>
      <ul class="dropdown-menu" role="menu">
      {$li}
      </ul>
    </div>
BUTTON;
        return $button;
    }
Example #17
0
 /**
  * Create a new instance.
  *
  * @return void
  */
 public function __construct()
 {
     //Set API base url if empty
     if (empty($this->apiBaseUrl)) {
         $this->apiBaseUrl = URL::to('/');
     }
     //Set API url if empty
     if (empty($this->apiUrl)) {
         $this->apiUrl = $this->apiBaseUrl . '/api/' . $this->apiVersion;
     }
     //Get the webste OAuth Client credentials
     $oauthClient = OauthClient::where('name', '=', 'website')->first();
     if (is_object($oauthClient)) {
         $this->clientId = $oauthClient->id;
         $this->clientSecret = $oauthClient->secret;
     }
     unset($oauthClient);
     Blade::extend(function ($view) {
         return preg_replace(array('#@translate\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@translate\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Translate::t("$1")', 'Translate::t(\'$1\')'), $view);
     });
     Blade::extend(function ($view) {
         return preg_replace(array('#@option\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@option\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Option::getAttribute(\'$1\')', 'Option::getAttribute(\'$1\')'), $view);
     });
     Blade::extend(function ($view) {
         return preg_replace(array('#@hasPermission\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@hasPermission\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Access::has(\'$1\')', 'Access::has(\'$1\')'), $view);
     });
     $this->getAccessToken();
     View::share('basePath', Request::getBaseURL());
 }
 public function setBest(Request $request, $id)
 {
     $comment = GuideComment::findOrFail($id);
     $comment->isbest = $request->input('value');
     $comment->save();
     return redirect(URL::previous());
 }
Example #19
0
 public function build()
 {
     $output = "";
     $this->attributes["class"] = "form-control";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "</div>";
             break;
         case "create":
         case "modify":
             Rapyd::js('packages/zofe/rapyd/assets/tinymce/tinymce.min.js');
             $output = Form::textarea($this->db_name, $this->value, $this->attributes);
             $output .= Rapyd::script("\n          tinymce.init({\n            selector: 'textarea#" . $this->name . "',\n            plugins: [\n                 'advlist autolink link image lists charmap print preview hr anchor pagebreak',\n                 'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',\n                 'save table contextmenu directionality emoticons template paste textcolor responsivefilemanager'\n            ],\n            toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | responsivefilemanager | print preview media fullpage | forecolor backcolor emoticons', \n            image_advtab: true ,\n            external_filemanager_path:'" . URL::to('/') . "/packages/filemanager/',\n            filemanager_title:'Upload',\n          });");
             break;
         case "hidden":
             $output = Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
 public function setTop($id, $result, Request $request)
 {
     $note = Note::findOrFail($id);
     $note->istop = $result;
     $note->save();
     return redirect(URL::previous());
 }
Example #21
0
 /**
  * Add a root if the URL is relative (helper method of the hasLink function).
  *
  * @return string
  */
 protected function absoluteUrl()
 {
     if (!Str::startsWith($this->url, ['http', 'https'])) {
         return URL::to($this->url);
     }
     return $this->url;
 }
Example #22
0
    /**
     * Generate the html for the given items
     * @param $items
     */
    private function generateHtmlFor($items)
    {
        $this->menu .= '<ol class="dd-list">';
        foreach ($items as $item) {
            $this->menu .= "<li class=\"dd-item\" data-id=\"{$item->id}\">";
            $editLink = URL::route('dashboard.menuitem.edit', [$this->menuId, $item->id]);
            $style = $item->isRoot() ? 'none' : 'inline';
            $this->menu .= <<<HTML
<div class="btn-group" role="group" aria-label="Action buttons" style="display: {$style}">
    <a class="btn btn-sm btn-info" style="float:left;" href="{$editLink}">
        <i class="fa fa-pencil"></i>
    </a>
    <a class="btn btn-sm btn-danger jsDeleteMenuItem" style="float:left; margin-right: 15px;" data-item-id="{$item->id}">
       <i class="fa fa-times"></i>
    </a>
</div>
HTML;
            $handleClass = $item->isRoot() ? 'dd-handle-root' : 'dd-handle';
            if (isset($item->icon) && $item->icon != '') {
                $this->menu .= "<div class=\"{$handleClass}\"><i class=\"{$item->icon}\" ></i> {$item->title}</div>";
            } else {
                $this->menu .= "<div class=\"{$handleClass}\">{$item->title}</div>";
            }
            if ($this->hasChildren($item)) {
                $this->generateHtmlFor($item->items);
            }
            $this->menu .= '</li>';
        }
        $this->menu .= '</ol>';
    }
Example #23
0
 public function __toString()
 {
     $location = $this->getLocation();
     $location = substr($location, 0) === '/' ? $location : '/' . $location;
     $url = URLFacade::to($location);
     return $location === '/' ? $url . '/' : $url;
 }
 /**
  * Generate a URL to an application asset.
  *
  * @param  string  $path
  * @param  bool    $secure
  * @return string
  */
 protected function configAssetUrl($path, $secure = null)
 {
     static $assetUrl;
     // Remove this.
     $i = 'index.php';
     if (URL::isValidUrl($path)) {
         return $path;
     }
     // Finding asset url config.
     if (is_null($assetUrl)) {
         $assetUrl = \Config::get('theme.assetUrl', '');
     }
     // Using asset url, if available.
     if ($assetUrl) {
         $base = rtrim($assetUrl, '/');
         // Asset URL without index.
         $basePath = str_contains($base, $i) ? str_replace('/' . $i, '', $base) : $base;
     } else {
         if (is_null($secure)) {
             $scheme = Request::getScheme() . '://';
         } else {
             $scheme = $secure ? 'https://' : 'http://';
         }
         // Get root URL.
         $root = Request::root();
         $start = starts_with($root, 'http://') ? 'http://' : 'https://';
         $root = preg_replace('~' . $start . '~', $scheme, $root, 1);
         // Asset URL without index.
         $basePath = str_contains($root, $i) ? str_replace('/' . $i, '', $root) : $root;
     }
     return $basePath . '/' . $path;
 }
Example #25
0
 public function postImageUpload(Request $request)
 {
     //        $j = 0;
     //        $target_path = "uploads/";
     //        for ($i = 0; $i < count($_FILES['file']['name']); $i++) {
     //            $ext = explode('.', basename($_FILES['file']['name'][$i]));
     //            $file_extension = end($ext);
     //            $target_path = $target_path . md5(uniqid()) . "." . $ext[count($ext) - 1];
     //            $j = $j + 1;
     //            move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path);
     //        }
     $images = new Picture();
     if ($request->hasFile('images')) {
         $listImage = array();
         $files = $request->file('images');
         foreach ($files as $file) {
             $name = $file->getClientOriginalName();
             $extension = $file->getClientOriginalExtension();
             $picture = time() . $name . '.' . $extension;
             $file->move('images/product', $picture);
             $src = 'images/product/' . $picture;
             $product_id = 1;
             $data = array('productID' => $product_id, 'imageName' => $name, 'imageSrc' => $src);
             autoAssignDataToProperty($images, $data);
             $listImage[] = $data;
         }
         $images->insert($listImage);
         return redirect(URL::to('/demo/image_upload'))->withSuccess('Image Upload');
     } else {
     }
 }
 private function redirectToPage($page, $request)
 {
     $pageSlug = $page->slug;
     $url = URL::to('/') . '/' . $pageSlug;
     //reflash any flash messages
     $request->session()->reflash();
     return Redirect::to($url, 301);
 }
Example #27
0
 /** @test */
 public function it_generates_not_rewrite_url_if_config_value_is_false()
 {
     Config::shouldReceive('get')->once()->with("imgproxy::rewrite")->andReturn(false);
     URL::shouldReceive('to')->once()->with("packages/spescina/imgproxy/timthumb.php?w=100&h=70&zc=1&q=90&src=image/path/url.jpg")->andReturn("http://www.example.com/packages/spescina/imgproxy/timthumb.php?w=100&h=70&zc=1&q=90&src=image/path/url.jpg");
     $imgProxy = new Imgproxy();
     $url = $imgProxy->link("image/path/url.jpg", 100, 70);
     $this->assertEquals("http://www.example.com/packages/spescina/imgproxy/timthumb.php?w=100&h=70&zc=1&q=90&src=image/path/url.jpg", $url);
 }
Example #28
0
 public function destroy($id)
 {
     $Src = Images::find($id)->imageSrc;
     $imageSrc = URL::to('/') . '/' . $Src;
     File::delete($imageSrc);
     Images::find($id)->delete();
     return redirect(URL::previous())->withSuccess(Lang::get('messages.delete_success'));
 }
Example #29
0
 public function __construct()
 {
     $this->base_url = URL::to('/');
     $this->upload_path = public_path() . '/uploads/';
     $this->upload_url = $this->base_url . '/uploads/';
     $this->script_url = $this->base_url . '/upload/';
     $this->options = array('file_name' => uniqid());
 }
 public function getDrawResult()
 {
     $userId = $this->getRandomUserId();
     $user = $this->getUser($userId);
     $user['profileImage'] = URL::asset('uploads/' . $user->image);
     $response = array('status' => true, 'user' => $user);
     return Response::json($response);
 }