private function rebuildModelFromQuery($model)
 {
     // Recontsruct the Translation object
     $translation = new Translation(['id' => $model->tr_id, 'value' => $model->tr_value, 'locale' => $model->tr_locale, 'group_id' => $model->tr_group_id]);
     $translation->exists = true;
     // Atatch the Translation to the Model
     $group_id = $model->tr_group_id;
     $translations = new Translations($group_id);
     $translations->attach($translation);
     $model->translations[$group_id] = $translations;
     // Clean Model from injected translation keys
     foreach (['tr_id', 'tr_value', 'tr_locale', 'tr_group_id'] as $key) {
         unset($model->attributes[$key]);
         unset($model->original[$key]);
     }
     return $model;
 }
 public function test_Translations_collection()
 {
     // empty
     $translations = new Translations();
     $this->assertNull($translations->get('el'));
     $this->assertEquals($translations->has('el'), false);
     // set
     $translations->set('el', 'Ελληνικά');
     $this->assertEquals($translations->has('el'), true);
     $translations = new Translations($translations->group_id);
     $this->assertEquals($translations->has('el'), true);
     $this->assertInstanceOf(Translation::class, $translations->get('el'));
     $this->assertEquals($translations->in('el'), 'Ελληνικά');
     // update
     $translations->set('el', 'Δευτέρα');
     $translations->set('en', 'Monday');
     $translations = new Translations($translations->group_id);
     $this->assertEquals($translations->in('el'), 'Δευτέρα');
     $this->assertEquals($translations->has('en'), true);
     // Not found
     $this->assertEquals('', $translations->in('invalid'));
 }