public function postItems(Request $request) { if (strlen($request->get('translate')) == 0) { throw new TranslationException(); } $base = \DB::table('translations')->select('name', 'value')->where('locale', $request->get('locale'))->where('group', $request->get('group'))->orderBy('name')->get(); $new = \DB::table('translations')->select('name', 'value')->where('locale', strtolower($request->get('translate')))->where('group', $request->get('group'))->orderBy('name'); $new = ServiceProvider::pluckOrLists($new, 'value', 'name'); foreach ($base as &$item) { $translate = null; if (array_key_exists($item->name, $new)) { $translate = $new[$item->name]; } $item->translation = $translate; } return $base; }
/** * Load the messages for the given locale. * * @param string $locale * @param string $group * @param string $namespace * @return array */ public function load($locale, $group, $namespace = null) { $query = \DB::table('translations')->where('locale', $locale)->where('group', $group); return ServiceProvider::pluckOrLists($query, 'value', 'name'); }