src/Controller.php
public function postMissingKeys()
    {
        $missingKeys = Request::json('missingKeys');

        // always on the default connection
        $this->manager->setConnectionName('');

        /* @var $translator \Vsch\TranslationManager\Translator */
        $translator = App::make('translator');

        $affectedGroups = [];
        foreach ($missingKeys as $key) {
            $key = decodeKey($key);
            list($namespace, $group, $item) = $translator->parseKey($key);
            if ($item && $group) {
                if (!in_array($group, $this->manager->config(Manager::EXCLUDE_GROUPS_KEY))) {
                    $t = $this->manager->missingKey($namespace, $group, $item, null, false, true);
                    if (!$t->exists) {
                        $affectedGroups[] = $t->group;
                        $t->save();
                    }
                }
            } else {
                // TODO: return error invalid key
            }
        }

        $data = [
            'connectionName' => '',
            'affectedGroups' => $affectedGroups,
            'missingKeys' => [],
        ];

        $pretty = Request::has('pretty-json') ? JSON_PRETTY_PRINT : 0;
        return Response::json($data, 200, [], JSON_UNESCAPED_SLASHES | $pretty);
    }
public function postMissingKeys()
    {
        $missingKeys = Request::json('missingKeys');

        // always on the default connection
        $this->manager->setConnectionName('');

        /* @var $translator \Vsch\TranslationManager\Translator */
        $translator = App::make('translator');

        $affectedGroups = [];
        foreach ($missingKeys as $key) {
            $key = decodeKey($key);
            list($namespace, $group, $item) = $translator->parseKey($key);
            if ($item && $group) {
                if (!in_array($group, $this->manager->config(Manager::EXCLUDE_GROUPS_KEY))) {
                    $t = $this->manager->missingKey($namespace, $group, $item, null, false, true);
                    if (!$t->exists) {
                        $affectedGroups[] = $t->group;
                        $t->save();
                    }
                }
            } else {
                // TODO: return error invalid key
            }
        }

        $data = [
            'connectionName' => '',
            'affectedGroups' => $affectedGroups,
            'missingKeys' => [],
        ];

        $pretty = Request::has('pretty-json') ? JSON_PRETTY_PRINT : 0;
        return Response::json($data, 200, [], JSON_UNESCAPED_SLASHES | $pretty);
    }
public function postMissingKeys ( ) { $ missingKeys = Request :: json ( 'missingKeys' ) ; // always on the default connection $ this -> manager -> setConnectionName ( '' ) ; /* @var $translator \Vsch\TranslationManager\Translator */ $ translator = App :: make ( 'translator' ) ; $ affectedGroups = [ ] ; foreach ( $ missingKeys as $ key ) { $ key = decodeKey ( $ key ) ; list ( $ namespace , $ group , $ item ) = $ translator -> parseKey ( $ key ) ; if ( $ item && $ group ) { if ( ! in_array ( $ group , $ this -> manager -> config ( Manager :: EXCLUDE_GROUPS_KEY ) ) ) { $ t = $ this -> manager -> missingKey ( $ namespace , $ group , $ item , null , false , true ) ; if ( ! $ t -> exists ) { $ affectedGroups [ ] = $ t -> group ; $ t -> save ( ) ; } } } else { // TODO: return error invalid key } } $ data = [ 'connectionName' => '' , 'affectedGroups' => $ affectedGroups , 'missingKeys' => [ ] , ] ; $ pretty = Request :: has ( 'pretty-json' ) ? JSON_PRETTY_PRINT : 0 ; return Response :: json ( $ data , 200 , [ ] , JSON_UNESCAPED_SLASHES | $ pretty ) ; }
Handles missing keys from the React App

@return \Illuminate\Http\JsonResponse provides affected groups so translations table can be reloaded
Handles missing keys from the React App