for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Modules\Core\Internationalisation;
/**
* Class Helper
* @package Modules\Core\Internationalisation
*/
class Helper
{
* Save the given model properties in all given languages
* @param $model
* @param $data
public static function updateTranslated($model, $data)
self::saveTranslatedProperties($model, $data);
}
* Create the given model and save its translated attributes
public static function createTranslatedFields($model, $data)
$model = new $model();
* Separate the input fields into their own language key
* @return array
public static function separateLanguages($data)
$cleanedData = [];
foreach ($data as $key => $value) {
if (is_array($value)) {
foreach ($value as $lang => $input) {
$cleanedData[$lang][$key] = $input;
} else {
$cleanedData[$key] = $value;
return $cleanedData;
* Save the given properties for the model
private static function saveTranslatedProperties($model, $data)
foreach ($data as $lang => $value) {
foreach ($value as $key => $input) {
$model->translate($lang)->$key = $input;
$model->save();