Example #1
2
 public function adAnnounce(Request $request)
 {
     $data = ["name" => $request->name, "email" => $request->email, "phone" => $request->phone, "description" => $request->description, "chambres" => $request->chambres, "pieces" => $request->pieces, "surface" => $request->surface, "prix" => $request->prix, "aid" => $request->aid];
     $file = null;
     $data["email"] = $request->email;
     $input = array('image' => Input::file('image'));
     $rules = array('image' => 'image');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         return response()->json(['data' => 'Fichier invalid', 'state' => false]);
     } else {
         if ($request->hasFile('image')) {
             $file = $request->file('image');
             $filename = $file->getClientOriginalName();
             $destinationPath = public_path() . '/uploads/ad';
             $file->move($destinationPath, $filename);
             $data['image'] = asset('uploads/ad/' . $filename);
             $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
             $collection = new \MongoDB\Collection($manager, 'builders', 'ads');
             $stat = ['email' => $request->email, 'data' => $data, 'created' => new \DateTime("now")];
             try {
                 $collection->insertOne($stat);
             } catch (\Exception $e) {
                 return response()->json(['state' => false]);
             }
             return response()->json(['data' => $data, 'state' => true]);
         }
     }
 }
Example #2
1
 public function pageCreateView($context, $alias, $value = [])
 {
     $menuLevel = [];
     $page = $this->pageModel($context, $alias);
     SEO::setTitle($page->title);
     SEO::setDescription($page->description);
     if ($page->image) {
         SEO::addImages(asset($page->image));
     }
     $value['page'] = $page;
     if ($page->comments and $this->view_comments) {
         $page->load('comments', 'comments.user');
         $value['comments'] = $page->comments;
     }
     $value['view_comments'] = $this->view_comments;
     if ($page->menu) {
         $page->menu->setActiveThis();
         $menuLevel = $page->menu->getMapLevel(true);
         if ($this->list) {
             $childs = $page->menu->getChildsId(true);
             $list = Page::active()->where('context', $this->list)->whereIn('menu_id', $childs)->sort()->with('user', 'fields', 'tag')->paginate(15);
             $value['list'] = $list;
         }
     }
     foreach ($menuLevel as $key => $val) {
         $value['menu_level_' . $key] = $val;
     }
     if ($this->template) {
         $view = $this->view($this->template, $value);
     } else {
         $view = $this->view('tpl.' . $page->template, $value);
     }
     return $view;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $id = Auth::user()->ID;
     $files = Input::file('files');
     $assetPath = '/uploads/' . $id;
     $uploadPath = public_path($assetPath);
     $results = array();
     foreach ($files as $file) {
         if ($file->getSize() > $_ENV['max_file_size']) {
             $results[] = array("name" => $file->getClientOriginalName(), "size" => $file->getSize(), "error" => "Please upload file less than " . $_ENV['max_file_size'] / 1000000 . "mb");
         } else {
             //rename filename so that it won't overlap with existing file
             $extension = $file->getClientOriginalExtension();
             $filename = time() . Str::random(20) . "." . $extension;
             // store our uploaded file in our uploads folder
             $name = $assetPath . '/' . $filename;
             $photo_attributes = array('name' => $filename, 'size' => $file->getSize(), 'url' => asset($name), 'user_id' => $id);
             $photo = new Photo($photo_attributes);
             if ($photo->save()) {
                 if (!is_dir($uploadPath)) {
                     mkdir($uploadPath, 0777);
                 }
                 //resize image into different sizes
                 foreach (Photo::getThumbnailSizes() as $key => $thumb) {
                     Image::make($file->getRealPath())->resize($thumb['width'], $thumb['height'])->save($uploadPath . "/" . $key . "-" . $filename);
                 }
                 //save original file
                 $file->move($uploadPath, $filename);
                 $results[] = Photo::find($photo->id)->find_in_json();
             }
         }
     }
     // return our results in a files object
     return json_encode(array('files' => $results));
 }
Example #4
0
/**
 * Get the current path to assets stored as a theme
 *
 * @param string $asset
 * @param null $theme
 * @return string
 */
function assetTheme($asset = '', $theme = null)
{
    if ($theme == null) {
        $theme = theme();
    }
    return asset('assets/' . $theme . '/' . $asset);
}
Example #5
0
function assets($name = "assets", $path_url = 0)
{
    if ($path_url) {
        return base_path() . config("path." . $name);
    }
    return asset(config("path." . $name));
}
Example #6
0
 /**
  * @return mixed
  */
 public function index()
 {
     $notas = Post::all();
     $imgem = asset('img/paris1.jpg');
     $view = view('blog/index')->with('imagem', $imgem)->with(compact('notas'));
     return $view;
 }
Example #7
0
 /**
  * @param Layout $someLayout
  * @return string
  */
 protected function wrapper(Layout $someLayout)
 {
     $t = $someLayout->getTag();
     /** @noinspection PhpMethodParametersCountMismatchInspection */
     /** @noinspection PhpUndefinedMethodInspection */
     return $t->div(a::id('wrapper'), $t->header(a::c1ass('main-header'), $t->a(a::c1ass('logo'), a::href('/dashboard'), $t->span(a::c1ass('logo-mini'), $t->img(a::src(asset('img/logo-39-45.png')), a::style('margin: 0 0 0 7%;')), $t->b('Solvre')), $t->span(a::c1ass('logo-lg'), $t->img(a::src(asset('img/logo-fav-lg.png'))), $t->b('Solvre'))), $this->navbarTop($t)), $this->aside($t), $this->content());
 }
Example #8
0
File: Topic.php Project: enhive/vev
 public function getImageAttribute($value)
 {
     if ($value) {
         return asset('uploads/topics/' . $value);
     }
     return asset('img/default-topic.jpg');
 }
Example #9
0
 /**
  * Generate a link to a CSS file.
  *
  * @param string $url
  * @param array  $attributes
  * @param bool   $secure
  *
  * @return \Illuminate\Support\HtmlString
  */
 public function style($url, $attributes = [], $secure = null)
 {
     $defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
     $attributes = $attributes + $defaults;
     $attributes['href'] = asset($url, $secure);
     return $this->toHtmlString('<link' . $this->attributes($attributes) . '>');
 }
Example #10
0
 public static function uploadTextarea($texto, $tipo_midia)
 {
     $nomeTipo = TipoMidia::findOrFail($tipo_midia)->descricao;
     // gravando imagem do corpo da noticia
     $dom = new \DOMDocument();
     $dom->loadHtml($texto, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
     $images = $dom->getElementsByTagName('img');
     // foreach <img> in the submited message
     foreach ($images as $img) {
         $src = $img->getAttribute('src');
         // if the img source is 'data-url'
         if (preg_match('/data:image/', $src)) {
             // get the mimetype
             preg_match('/data:image\\/(?<mime>.*?)\\;/', $src, $groups);
             $mimetype = $groups['mime'];
             // Generating a random filename
             $filename = md5(uniqid());
             $filepath = "uploads/" . $nomeTipo . "/" . $filename . '.' . $mimetype;
             // @see http://image.intervention.io/api/
             $image = Image::make($src)->encode($mimetype, 100)->save(public_path($filepath));
             $new_src = asset($filepath);
             $img->removeAttribute('src');
             $img->setAttribute('src', $new_src);
         }
     }
     return $dom->saveHTML();
 }
Example #11
0
 function show()
 {
     if ($_GET['id']) {
         return _class('docs')->_show_for($this);
     }
     $docs = _class('docs');
     asset('font-awesome4');
     foreach ($this->_get_assets() as $a) {
         $name = $a['name'];
         $sub = [];
         $sub[] = $docs->_github_link($a['path']);
         $content = $a['content'];
         $info = is_array($content) ? $content['info'] : [];
         if ($info['name']) {
             $sub[] = '<b>' . t('name') . '</b>: ' . $info['name'];
         }
         if ($info['desc']) {
             $sub[] = '<b>' . t('desc') . '</b>: ' . $info['desc'];
         }
         if ($info['url']) {
             $sub[] = '<b>' . t('url') . '</b>: <a href="' . _prepare_html($info['url']) . '">' . _prepare_html($info['url']) . '</a>';
         }
         if ($info['git']) {
             $sub[] = '<b>' . t('git') . '</b>: <a href="' . $info['git'] . '">' . $info['git'] . '</a>';
         }
         $data[$name] = ['name' => $name, 'link' => url('/@object/@action/#' . $name), 'sub' => $sub, 'id' => $name];
     }
     return html()->li($data);
 }
Example #12
0
    public static function html($item)
    {
        switch ($item->field) {
            case 'text':
                $value = isset($item->value->text) ? $item->value->text : '';
                $html = '<input id="extend_' . $item->key . '" name="extend[' . $item->key . ']" type="text" value="' . $value . '">';
                break;
            case 'html':
                $value = isset($item->value->html) ? $item->value->html : '';
                $html = '<textarea id="extend_' . $item->key . '" name="extend[' . $item->key . ']" type="text">' . $value . '</textarea>';
                break;
            case 'image':
            case 'file':
                $value = isset($item->value->filename) ? $item->value->filename : '';
                $html = '<span class="current-file">';
                if ($value) {
                    $html .= '<a href="' . asset('content/' . $value) . '" target="_blank">' . $value . '</a>';
                }
                $html .= '</span>
					<span class="file">
					<input id="extend_' . $item->key . '" name="extend[' . $item->key . ']" type="file">
					</span>';
                if ($value) {
                    $html .= '</p><p>
					<label>Remove ' . $item->label . ':</label>
					<input type="checkbox" name="extend_remove[' . $item->key . ']" value="1">';
                }
                break;
            default:
                $html = '';
        }
        return $html;
    }
 /**
  * Proccess image and write the text
  * Verify if the image needs to be downloaded
  * @param Request $request
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['top' => 'max:' . Image::$maxCharCount, 'bottom' => 'required|max:' . Image::$maxCharCount, 'image' => 'required']);
     if ($validator->fails()) {
         $errors = '';
         foreach ($validator->errors()->all() as $error) {
             $errors .= "<br/>" . $error;
         }
         return response('Erro(s) de validação: ' . $errors, 500);
     }
     $image = $request->get('image');
     if (substr($image, -4) !== '.jpg') {
         $image .= '.jpg';
     }
     $imageObject = $this->manager->make(public_path() . '/images/' . $image);
     $token = Image::generateImageToken();
     $path = public_path() . '/images/' . $token . '.jpg';
     $imageObject = $this->write($imageObject, $request->get('bottom'));
     if ($request->get('top')) {
         $imageObject = $this->write($imageObject, $request->get('top'), 'top');
     }
     $result = $imageObject->save($path);
     if ($result) {
         return ['message' => 'Your image was saved successfully', 'token' => $token, 'image_src' => asset('images/' . $token . '.jpg')];
     }
 }
Example #14
0
 public function index()
 {
     //
     Visitor::log();
     $cats = Categories::orderBy('sort_id', 'asc')->get();
     $products = Products::orderBy('sort_id', 'asc')->get();
     Setting::get('config.mainprod', Null) ? $mainProdImg = asset('/files/img/' . Setting::get('config.mainprod')) : ($mainProdImg = asset('dist/img/photo4.jpg'));
     Setting::get('config.logo', Null) ? $logoMain = asset('/files/img/' . Setting::get('config.logo')) : ($logoMain = asset('dist/img/logo.png'));
     $topProds = DB::table('order_items')->select('product_id', DB::raw('count(*) as total'))->groupBy('product_id')->orderBy('total', 'desc')->take('5')->get();
     $topProdsArr = [];
     foreach ($topProds as $topprod) {
         if (!in_array($topprod->product_id, ['fast', 'np', 'gift'])) {
             if (strpos($topprod->product_id, '0000')) {
                 //dd('consist');
                 $pID = explode('0000', $topprod->product_id);
                 //$topprod->product_id = $pID[0];
                 $prodID = $pID[0];
             } else {
                 $prodID = $topprod->product_id;
             }
             $prodName = Products::findOrFail($prodID);
             //echo $prodName->name;
             array_push($topProdsArr, ['name' => $prodName->name, 'cover' => $prodName->cover, 'link' => $prodName->urlhash]);
         }
         // code...
     }
     //dd(collect($topProdsArr));
     $data = ['cats' => $cats, 'products' => $products, 'PageDescr' => Setting::get('config.maindesc'), 'PageWords' => Setting::get('config.mainwords'), 'PageAuthor' => '', 'PageTitle' => Setting::get('config.maintitle'), 'mainProdImg' => $mainProdImg, 'logoMain' => $logoMain, 'topProds' => $topProdsArr, 'totalNavLabel' => $this->totalNavLabel()];
     return view('catalogPage')->with($data);
 }
Example #15
0
 /**
  * Generate an asset path for the application.
  *
  * @param  string  $path
  * @param  bool    $secure
  * @return string
  */
 public function asset($path, $secure = null)
 {
     if (function_exists('asset')) {
         return asset($path, $secure);
     }
     return $path;
 }
Example #16
0
 public function getAvatarUrl()
 {
     if (!$this->avatar) {
         return asset('images/avatars/default.png');
     }
     return $this->avatar->getFileUrl();
 }
Example #17
0
 /**
  */
 function _preload_data()
 {
     if ($this->_preload_complete) {
         return true;
     }
     $this->_preload_complete = true;
     asset('bfh-select');
     $this->lang_def_country = main()->get_data('lang_def_country');
     $this->_boxes = ['lang_code' => 'select_box("lang_code",		$this->_langs,			$selected, false, 2, "", false)', 'cur_langs' => 'select_box("lang_code",		$this->_cur_langs,		$selected, false, 2, "", false)', 'file_format' => 'radio_box("file_format",	$this->_file_formats,	$selected, true, 2, "", false)', 'mode' => 'radio_box("mode",			$this->_modes,			$selected, true, 2, "", false)', 'search_type' => 'radio_box("search_type",	$this->_search_types,	$selected, false, 2, "", false)', 'location' => 'select_box("location",		$this->_used_locations,	$selected, false, 2, "", false)', 'module' => 'select_box("module",		$this->_modules,		$selected, false, 2, "", false)'];
     $this->_modules = _class('admin_methods')->find_active_modules();
     $langs = [];
     foreach ((array) $this->_get_iso639_list() as $lang_code => $lang_params) {
         $langs[$lang_code] = t($lang_params[0]) . (!empty($lang_params[1]) ? ' (' . $lang_params[1] . ') ' : '');
     }
     $this->_langs = $langs;
     $this->_cur_langs_array = db()->get_all('SELECT * FROM ' . db('locale_langs') . ' ORDER BY is_default DESC, locale ASC');
     if (empty($this->_cur_langs_array)) {
         db()->insert_safe('locale_langs', ['locale' => 'en', 'name' => t('English'), 'charset' => 'utf-8', 'active' => 1, 'is_default' => 1]);
         js_redirect('/@object/@action');
     }
     $langs_for_search[''] = t('All languages');
     foreach ((array) $this->_cur_langs_array as $A) {
         $langs_for_search[$A['locale']] = t($A['name']);
         $cur_langs[$A['locale']] = t($A['name']);
     }
     $this->_langs_for_search = $langs_for_search;
     $this->_cur_langs = $cur_langs;
     // TODO: add support for these file formats for import/export:
     // * JSON
     // * PHP
     // * GNU Gettext (.po)  http://www.gutenberg.org/wiki/Gutenberg:GNU_Gettext_Translation_How-To, https://en.wikipedia.org/wiki/Gettext
     $this->_file_formats = ['csv' => t('CSV, compatible with MS Excel'), 'xml' => t('XML')];
     $this->_modes = [1 => t('Strings in the uploaded file replace existing ones, new ones are added'), 2 => t('Existing strings are kept, only new strings are added')];
 }
 /**
  * Get Url with version
  *
  * @param $path
  * @return string
  * @throws LogicException
  */
 function url($path)
 {
     if (!file_exists($this->getRealPath($path))) {
         throw new LogicException("File not found at [{$this->getRealPath($path)}]");
     }
     return asset($this->bustQuery($path));
 }
Example #19
0
 public function Photo()
 {
     if ($this->avatar == null) {
         return cms_asset_path('img/pug.png');
     }
     return asset($this->avatar);
 }
Example #20
0
 public function getCover()
 {
     if ($this->cover()) {
         return asset('assets/info/' . module('Info')->cover());
     }
     return 'http://placehold.it/1280x720';
 }
Example #21
0
File: User.php Project: enhive/vev
 public function getImageAttribute($value)
 {
     if ($value == '') {
         return "http://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)) . '?d=' . asset('img/default-user.jpg'));
     }
     return $value;
 }
 public function store(AdministratorRequest $request, $id = null)
 {
     if ($id == null) {
         $administrator = new Administrators();
     } else {
         $administrator = Administrators::find($id);
     }
     $administrator->lastname = $request->nom;
     $administrator->firstname = $request->prenom;
     $administrator->email = $request->email;
     $administrator->super_admin = $request->super;
     if (!empty($request->password)) {
         $administrator->password = bcrypt($request->password);
     }
     $administrator->active = true;
     $administrator->expiration_date = new \DateTime('+1 year');
     $filename = "";
     if ($request->hasFile('image')) {
         //je recupere mon fichier :
         $file = $request->file('image');
         //je recupere le nom du fichier :
         $filename = $file->getClientOriginalName();
         //je stock le chemin veers lequel mon image va etre envoyé
         $destinationPath = public_path() . '/uploads/administrator';
         //je deplace mon fichier uploader :
         $file->move($destinationPath, $filename);
     }
     $administrator->photo = asset("uploads/administrator/" . $filename);
     $administrator->save();
     Session::flash('success', "L'administrators : {$administrator->firstname} a bien été ajouté !");
     return Redirect::route('administrators_index');
     //recupere le film de mon film ac la methode POST
     //input (name de mon champ) permet de recuperer la donée titre de maniere safely
 }
Example #23
0
 public function upload(Request $request)
 {
     $file = Input::file('file');
     if (null === $file) {
         return 'Не удалось загрузить изображение';
     }
     if ($file->isValid()) {
         $image = Image::make($file);
         $path = 'upload/' . date("Y") . '/' . date('m') . '/' . date('d');
         $extension = File::extension($file->getClientOriginalName());
         $filename = uniqid() . '.' . $extension;
         if (!is_dir($path)) {
             mkdir(public_path($path), 0777, true);
         }
         $path .= '/';
         $background = Image::canvas(1200, 900, '#111111');
         $image->backup()->heighten(900)->widen(1200, function ($constraint) {
             $constraint->upsize();
         });
         $image->insert(asset('img/watermark.png'), 'bottom-right', 20, 20);
         $background->insert($image, 'center');
         $background->save($path . "original_" . $filename);
         unset($background);
         $image->reset()->fit(160, 120);
         $image->save($path . "small_" . $filename);
         unset($image);
         return ['small' => $path . "original_" . $filename, 'big' => $path . "small_" . $filename];
     } else {
         return response('Invalid file', 400);
     }
 }
Example #24
0
 public function jsonMedia()
 {
     $dirfiles = $this->dirToArray(config('app.media_path'), asset('media'), 1);
     $images = $this->onlyImages($dirfiles);
     echo json_encode($images);
     exit(1);
 }
Example #25
0
 /**
  * Retourne l'avatar d'un membre
  *
  * @param string $size
  * @return string
  */
 public function avatar($size = 'default')
 {
     if (Gravatar::exists($this->email)) {
         return Gravatar::get($this->email, $size);
     }
     return asset('images/anonymous.jpg');
 }
Example #26
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($profile) {
         $profile->profile_pic = asset('img/avatar.png');
     });
 }
Example #27
0
 /**
  */
 function show()
 {
     asset('jquery-jstree');
     $slick_view = isset($_GET['CKEditorFuncNum']);
     $body = tpl()->parse(__CLASS__ . '/main', ['ck_funcnum' => (int) $_GET['CKEditorFuncNum']]);
     return $slick_view ? print common()->show_empty_page($body) : $body;
 }
Example #28
0
 function __construct()
 {
     // var_dump(session()->get('tour_comparison'));
     // session()->flush('tour_comparison');
     ///////////////////
     // Init Template //
     ///////////////////
     $this->version = env('WEB_VERSION', 'default');
     $this->layout = view($this->version . '.templates.html');
     $this->layout->basic = view($this->version . '.templates.static');
     /////////////////
     // Init Meta  //
     ////////////////
     $this->layout->metas = ['og:type' => 'website', 'og:title' => "Capcus.id - Cari paket tour jadi mudah", 'og:url' => URL::current(), 'og:image' => asset('images/logo-black-small.png'), 'og:image:type' => 'image/png', 'og:image:width' => 275, 'og:image:height' => 121, 'og:site_name' => 'capcus.id'];
     //////////////
     // Init API //
     //////////////
     $this->api_url = env('API_URL', 'http://api.capcus.id');
     $this->api = new \GuzzleHttp\Client(['base_url' => $this->api_url]);
     ////////////////
     // Init Alert //
     ////////////////
     foreach (Session::all() as $k => $v) {
         if (str_is('_alert_*', $k)) {
             $this->layout->{$k} = $v;
         }
     }
     /////////////////////////////////////
     // Prepare options for search tour //
     /////////////////////////////////////
     $this->SearchTourOptions();
     $this->ViewCounter();
     $this->layout->basic->search_tour_options = $this->search_tour_options;
 }
Example #29
0
 /**
  * Get the URL to uploads folder
  *
  * @param  string  $path
  * @param  bool    $secure
  * @return string
  */
 function uploads($upload)
 {
     if (file_exists(public_path() . 'uploads/' . $upload)) {
         return 'no image broh';
     }
     return asset('uploads/' . ltrim($upload, '/'));
 }
Example #30
0
 function vasset($asset)
 {
     if (!config('app.debug')) {
         $asset = preg_replace('/(.*?)\\.(js|css)$/', '$1.min.$2', $asset);
     }
     return asset($asset);
 }