Ejemplo n.º 1
1
 public function contact()
 {
     $title = 'Contact';
     $name = App::getLocale() == 'fr' ? 'name_fr' : 'name_en';
     if (App::getLocale() == 'fr') {
         $iams = [1 => 'Indépendant', 2 => 'Particulier', 3 => 'Organisme public'];
     } else {
         $iams = [1 => 'Professional client', 2 => 'Private client', 3 => 'Public body'];
     }
     $objects = Object::lists($name, 'id');
     return view('pages.contact', compact('title', 'objects', 'iams'));
 }
Ejemplo n.º 2
0
 /**
  * @param $request
  * @param Closure $next
  * @return \Illuminate\Http\JsonResponse
  */
 public function handle($request, Closure $next)
 {
     $localCode = strtoupper(App::getLocale());
     $vrfArr = array('id', 'firstName', 'lastName', 'email', 'title', 'content');
     $verify = true;
     switch ($localCode) {
         case "VI":
             $fail = "Vui lòng điền đầy đủ thông tin và thử lại.";
             break;
         case "EN":
             $fail = "Please enter fully information.";
             break;
         default:
             $fail = "Please enter fully information.";
             break;
     }
     for ($i = 0; $i < count($vrfArr); $i++) {
         if ($request->input($vrfArr[$i]) == null || $request->input($vrfArr[$i]) == '') {
             $verify = false;
         }
     }
     if ($verify == false) {
         return response()->json(['info' => 'Fail', 'Content' => $vrfArr], 200);
     } else {
         return $next($request);
     }
 }
 public function getInputs($inputs)
 {
     $inputs['datetime_ini'] = HelperRepository::date($inputs['datetime_ini'], App::getLocale());
     $inputs['datetime_end'] = HelperRepository::date($inputs['datetime_end'], App::getLocale());
     $inputs['cost'] = HelperRepository::money($inputs['cost'], App::getLocale());
     return $inputs;
 }
Ejemplo n.º 4
0
 /**
  * Get online root elements
  *
  * @param  int    $menuId
  * @return object
  */
 public function rootsForMenu($menuId)
 {
     return $this->model->whereHas('translations', function (Builder $q) {
         $q->where('status', 1);
         $q->where('locale', App::getLocale());
     })->with('translations')->whereMenuId($menuId)->orderBy('position')->get();
 }
Ejemplo n.º 5
0
 /**
  * Return available payment methods by country and payment group
  * Method parameters can be set via config
  *
  * @param string [Optional] $country
  * @param array [Optional] $payment_groups_names
  * @return array
  */
 public static function getPaymentMethods($country = null, $payment_groups_names = null)
 {
     $payment_methods_info = WebToPay::getPaymentMethodList(intval(config('paysera.projectid')), config('paysera.currency'));
     $country_code = !is_null($country) ? $country : strtolower(config('paysera.country'));
     $payment_methods_info->setDefaultLanguage(App::getLocale());
     $result = [];
     $country_payment_methods_info = $payment_methods_info->getCountry($country_code);
     $result['country_code'] = $country_payment_methods_info->getCode();
     $result['country_title'] = $country_payment_methods_info->getTitle();
     $payment_methods_groups_all = $country_payment_methods_info->getGroups();
     if ($payment_groups_names == null) {
         $payment_groups_names = config('paysera.payment_groups');
     }
     foreach ($payment_groups_names as $payment_groups_name) {
         $payment_methods_groups[$payment_groups_name] = $payment_methods_groups_all[$payment_groups_name];
         $result['payment_groups'][$payment_groups_name]['title'] = $payment_methods_groups_all[$payment_groups_name]->getTitle(App::getLocale());
         foreach ($payment_methods_groups_all[$payment_groups_name]->getPaymentMethods() as $key => $method) {
             $tmp = [];
             $tmp['title'] = $method->getTitle(App::getLocale());
             $tmp['key'] = $key;
             $tmp['currency'] = $method->getBaseCurrency();
             $tmp['logo_url'] = $method->getLogoUrl();
             $tmp['object'] = $method;
             $result['payment_groups'][$payment_groups_name]['methods'][$key] = $tmp;
         }
     }
     return $result;
 }
Ejemplo n.º 6
0
 public function getLocaleOf($page)
 {
     $locale = App::getLocale();
     //$data = Texts::all()->where('slug','=', $page)->where('lang','=', $locale);
     $data = DB::table('texts')->where('slug', '=', $page)->where('lang', '=', $locale)->first();
     return $data;
 }
Ejemplo n.º 7
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $localCode = strtoupper(App::getLocale());
     $commonModel = new Models\CommonModel();
     switch ($localCode) {
         case "VI":
             $fail = "Vui lòng nhập email và thử lại.";
             $fail1 = "Email của bạn quá dài, vui lòng nhập lại.";
             $fail2 = "Email của bạn đã được đăng ký.";
             break;
         case "EN":
             $fail = "Please input your email!";
             $fail1 = "Your email is too long!";
             $fail2 = "This email already subscribe";
             break;
         default:
             $fail = "Please input your email!";
             $fail1 = "Your email is too long!";
             $fail2 = "This email already subscribe";
             break;
     }
     if ($request->input('email') == null || $request->input('email') == '') {
         return response()->json(['info' => 'Fail', 'Content' => $fail], 200);
     } elseif (strlen($request->input('email')) > 50) {
         return response()->json(['info' => 'Fail', 'Content' => $fail1], 200);
     } else {
         $exist = $commonModel->checkExistEmail($request->input('email'));
         if ($exist > 0) {
             return response()->json(['info' => 'Fail', 'Content' => $fail2], 200);
         } else {
             return $next($request);
         }
     }
 }
 public function __construct(Model $model = null, ElegantModelFieldInterface $field, $context = null, $locale = null)
 {
     $this->locale = $locale ?: App::getLocale();
     $this->model = $model;
     $this->field = $field;
     $this->context = $context;
 }
 public function __construct($lang = null)
 {
     // set langcode
     if (is_null($lang)) {
         $lang = App::getLocale();
     }
     $this->langCode = $lang . '_' . strtoupper($lang);
 }
Ejemplo n.º 10
0
 /**
  * Get all online menus
  * @return object
  */
 public function allOnline()
 {
     $locale = App::getLocale();
     return $this->model->whereHas('translations', function (Builder $q) use($locale) {
         $q->where('locale', "{$locale}");
         $q->where('status', 1);
     })->with('translations')->orderBy('created_at', 'DESC')->get();
 }
 /**
  * Returns the language translation for the given key, based on the app's current
  * locale setting.
  *
  * @param string $key
  * @return mixed
  */
 public function __get($key)
 {
     $lang = App::getLocale();
     if (isset($this->translated[$lang][$key])) {
         return $this->trans($lang, $key);
     }
     return parent::__get($key);
 }
Ejemplo n.º 12
0
 /**
  * @param $query
  * @param bool|false $data
  */
 public function scopeLanguage($query, $data = false)
 {
     if ($data === true) {
         $query->where('lang', App::getLocale())->orWhere('lang', '');
     } else {
         $query->where('lang', '=', App::getLocale());
     }
 }
 public function getInputs($inputs)
 {
     $inputs['pickup_date'] = HelperRepository::date($inputs['pickup_date'], App::getLocale());
     $inputs['deliver_date'] = HelperRepository::date($inputs['deliver_date'], App::getLocale());
     $inputs['fuel_cost'] = HelperRepository::money($inputs['fuel_cost'], App::getLocale());
     $inputs['fuel_amount'] = HelperRepository::money($inputs['fuel_amount'], App::getLocale());
     return $inputs;
 }
Ejemplo n.º 14
0
 function __construct()
 {
     $this->appid = Config::get('sweet-captcha::SWEETCAPTCHA_APP_ID');
     $this->key = Config::get('sweet-captcha::SWEETCAPTCHA_KEY');
     $this->secret = Config::get('sweet-captcha::SWEETCAPTCHA_SECRET');
     $this->path = Config::get('sweet-captcha::SWEETCAPTCHA_PUBLIC_URL');
     $this->language = strtoupper(Config::get('sweet-captcha::SWEETCAPTCHA_LANGUAGE') != '' ? Config::get('sweet-captcha::SWEETCAPTCHA_LANGUAGE') : App::getLocale());
 }
Ejemplo n.º 15
0
 /**
  * @param QuizWasCreated $event
  */
 public function handle(QuizWasCreated $event)
 {
     $quiz = Quiz::find($event->quiz->id);
     $title = $quiz->name;
     $link = App::getLocale() . '/quiz/' . $quiz->id;
     $user = User::find($event->user->id);
     $username = $user->name;
     $this->mailer->compose($user->email, $username, $title, $link)->send();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function ask(Request $request)
 {
     $data = $request->all();
     $selectedAuction = $data['id'];
     $locale = App::getLocale();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     $auctions = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->where('status_id', 1)->orderBy('created_at', 'DESC')->get();
     return view('contact.index', array('newest' => $newest, 'auctions' => $auctions, 'selected' => $selectedAuction));
 }
Ejemplo n.º 17
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return mixed
  */
 public function handle($request, \Closure $next)
 {
     $locale = $this->request->segment(1) ?: App::getLocale();
     $item = $this->menuItem->findByUriInLanguage($this->request->segment(2), $locale);
     if ($this->isOffline($item)) {
         App::abort(404);
     }
     return $next($request);
 }
Ejemplo n.º 18
0
 public function init($node, $method)
 {
     // FIXME: move paramter to config
     if (!$node->isActive(App::getLocale()) && !Input::has('show')) {
         App::abort(404);
     }
     $this->node = $node;
     return $this->{$method}();
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show(Request $request)
 {
     $data = $request->all();
     $query = $data['search'];
     $locale = App::getLocale();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     $results = Auction::search($query)->get();
     return view('search.show', array('results' => $results, 'newest' => $newest, 'query' => $query));
 }
Ejemplo n.º 20
0
 /**
  * Get the translation of the given field name
  * @param  string      $fieldName
  * @param  string|null $locale
  * @return string
  */
 public function translation($fieldName, $locale = null)
 {
     $locale = $locale ?: App::getLocale();
     foreach ($this->translation as $translation) {
         if ($translation->locale == $locale) {
             return $translation->{$fieldName};
         }
     }
 }
Ejemplo n.º 21
0
 public function notFoundPage()
 {
     $localCode = strtoupper(App::getLocale());
     /* Load Model */
     $headerModel = new Models\HeaderModel();
     /* Init Data */
     $headerData = $headerModel->index($localCode);
     $indexData = array("headerData" => $headerData);
     return view('404', $indexData);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $locale = App::getLocale();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     $myBids = Auction::join('bids', 'bids.auction_id', '=', 'auctions.id')->where('bids.user_id', Auth::User()->id)->translatedIn($locale)->get();
     /**
      * Return all acutions
      */
     return view('my_bids.index', array('auctions' => $myBids, 'newest' => $newest));
 }
Ejemplo n.º 23
0
 /**
  * Field constructor.
  * @param string $name 该字段的唯一标记, 同一个控件中不能存在相同name的field
  * @param string $description 描述、标签
  * @param Data $source 对应 Row
  */
 public function __construct(string $name, string $description = null, Data $source = null)
 {
     $this->name = $name;
     $this->column = $name;
     $this->description = $description;
     $this->source = $source;
     $this->locale(App::getLocale());
     // 默认使用 Laravel 的配置
     $this->triggerInitialize();
 }
Ejemplo n.º 24
0
 /**
  * Get the PhoneNumberUtil or format a phone number for display.
  *
  * @return \libphonenumber\PhoneNumberUtil|string
  */
 function phone()
 {
     $lib = App::make('libphonenumber');
     if (!($arguments = func_get_args())) {
         return $lib;
     }
     $phone = $arguments[0];
     $country = isset($arguments[1]) ? $arguments[1] : App::getLocale();
     $format = isset($arguments[2]) ? $arguments[2] : PhoneNumberFormat::INTERNATIONAL;
     return $lib->format($lib->parse($phone, $country), $format);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     try {
         $gallery = Gallery::with('pictures')->findOrFail($id);
     } catch (Exception $e) {
         return back()->with('error', trans('default.gallerynotfound'));
     }
     $title = $gallery->{'name_' . App::getLocale()};
     //$pictures = File::files(base_path() . '/public/images/galleries/' . $gallery->id);
     return view('galleries.show', compact('title', 'gallery'));
 }
Ejemplo n.º 26
0
 public function page($slug = 'index')
 {
     $view = implode('/', ['pages', $slug]);
     if (!View::exists($view)) {
         abort(404);
     }
     $locale = App::getLocale();
     $pageInMarkdown = base_path("resources/pages/{$locale}/{$slug}.md");
     $pageInHtml = file_exists($pageInMarkdown) ? (new ParsedownExtra())->text(File::get($pageInMarkdown)) : '';
     return view($view, ['slug' => $slug, 'html' => $pageInHtml]);
 }
Ejemplo n.º 27
0
 /**
  * Translate view name
  *
  * @param $name
  * @param string $delimiter
  * @return string
  */
 protected function translateView($name, $delimiter = '.')
 {
     $locale = App::getLocale();
     $explodedName = (array) explode($delimiter, $name);
     $replaceable = end($explodedName);
     $replaced = preg_replace("~{$replaceable}(?!.*{$replaceable})~", "{$locale}{$delimiter}{$replaceable}", $name);
     if (View::exists($replaced)) {
         return $replaced;
     }
     return $name;
 }
Ejemplo n.º 28
-1
 /**
  * [created_at]的mutator
  *
  * @param $value
  * @return string
  */
 public function getCreatedAtAttribute($value) : string
 {
     $locale = App::getLocale();
     $date = $this->asDateTime($value);
     if ($locale === 'uk') {
         return $date->format('d M, Y');
     } elseif ($locale === 'tw') {
         return $date->format('Y/m/d');
     } else {
         return $date->format('M d, Y');
     }
 }
Ejemplo n.º 29
-1
 private function setLocaleAsKey($tags)
 {
     $cleanedTags = [];
     foreach ($tags as $tag) {
         foreach ($tag->translations as $tagTranslation) {
             if (App::getLocale() == $tagTranslation->locale) {
                 $cleanedTags[] = ['id' => $tag->id, 'name' => $tagTranslation->name];
             }
         }
     }
     return $cleanedTags;
 }
Ejemplo n.º 30
-1
 /** pages navigator controller
  * @param $pageLink
  * @return View
  */
 public function getPagesRedirect($pageLink)
 {
     $localCode = strtoupper(App::getLocale());
     /* Load Mode */
     $headerModel = new Models\HeaderModel();
     $breadCrumbModel = new Models\breadCrumbsModel();
     $pageModel = new Models\PagesModel();
     /* Init Data */
     $headerData = $headerModel->index($localCode);
     $pageData = $pageModel->getPageIndex($localCode, $pageLink);
     $breadCrumbData = $breadCrumbModel->getBreadCrumbData($localCode, "pages", "P", $pageLink, null);
     $pageArray = array("headerData" => $headerData, "breadCrumb" => $breadCrumbData, "pages" => $pageData);
     return view('pages', $pageArray);
 }