/** * Run the database seeds. * * @return void */ public function run() { $locales = json_decode(file_get_contents(stryve_path() . '/Database/SeedData/locales.json')); $locales_array = []; foreach ($locales as $value) { $locales_array[] = ['locale' => $value, 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]; } $this->locale->insert($locales_array); }
/** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { $translates = Translate::all(); $locales = Locale::all(); $cols = 12 / $locales->count(); return view('messages.index', compact('translates', 'locales', 'cols')); }
public function __construct(PostTypeRepositoryInterface $postTypeRepos, PostRepositoryInterface $postRepos, TemplateRepositoryInterface $templateRepos, PostService $postService) { $this->postTypeRepos = $postTypeRepos; $this->postRepos = $postRepos; $this->templateRepos = $templateRepos; $this->postService = $postService; $this->authUser = Auth::user(); if (!$this->authUser->is('superadmin')) { App::abort(403, 'Access denied'); } //get the post type from the url param $routeParamters = Route::current()->parameters(); $postTypeId = $routeParamters['posttypeid']; $this->postType = $this->postTypeRepos->find($postTypeId); //get the categories, category check convert to route middleware $categoryRootId = $this->postType->getConfiguredRootCategory(); if (!$categoryRootId) { return Redirect::route('admin.post-types.configuration', [$postTypeId, "root"])->send(); } $root = Category::find($categoryRootId); if (!$root->descendants()->count()) { return Redirect::route('admin.post-types.configuration', [$postTypeId, "descendants"])->send(); } $categories = $root->descendants()->get(); foreach ($categories as $category) { $this->categories[$category->id] = $category->title; } //localization $this->locales = Locale::where('language', '!=', 'en')->lists('language', 'language'); $this->first_locale = array_first($this->locales, function () { return true; }); //share the post type submenu to the layout View::share('postTypesSubmenu', $this->postTypeRepos->renderMenu()); }
public function get_locale($lat, $long) { $cache_key = 'locale_data' . $lat . $long; $return = Cache::get($cache_key); if (!$return) { $locale_data = Locale::get_locale($lat, $long); $return = array('city' => $locale_data['city'], 'state' => $locale_data['state']); Cache::put($cache_key, $return, Config::get('mirror.cache_time')); } return $return; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Locale::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'city_id' => $this->city_id, 'latitude' => $this->latitude, 'longitude' => $this->longitude]); $query->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone]); return $dataProvider; }
/** * @param int $id * @param Request $request * @return \Illuminate\Http\Response */ public function destroy($id, Request $request) { $record = Locale::find($id); if ($record->delete()) { $request->session()->flash('message', 'Locale was successful!'); $request->session()->flash('alert', 'success'); } else { $request->session()->flash('message', 'Locale was successful!'); $request->session()->flash('alert', 'danger'); } return redirect('/locales'); }
/** * @return \Illuminate\Http\Response */ public function index() { return Locale::all(); }
/** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function edit($id) { $record = Translate::find($id); $locales = Locale::all(); return view('translates.edit', compact('record', 'locales')); }
/** * @param $slug * @return Locale */ private function getLocale($slug) { return Locale::whereSlug($slug)->first(); }
/** * Finds the Locale model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Locale the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Locale::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function run() { DB::table('locales')->delete(); Locale::create(['name' => 'pt-BR', 'label' => 'Portuguese', 'flag' => 'brazil']); }
/** * @return \yii\db\ActiveQuery */ public function getLocales() { return $this->hasMany(Locale::className(), ['city_id' => 'id']); }