Skip to content
Prev Previous commit
wip
  • Loading branch information
djaiss committed Feb 4, 2018
commit 9281a14389e776ff1b3230a6ab781c9738781a5a
11 changes: 11 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ public function getMetricSymbol()
}
}

/**
* Get the user's locale.
*
* @param string $value
* @return string
*/
public function getLocaleAttribute($value)
{
return $value;
}

/**
* Get users's full name. The name is formatted according to the user's
* preference, either "Firstname Lastname", or "Lastname Firstname".
Expand Down
4 changes: 4 additions & 0 deletions database/migrations/2018_01_27_014146_add_custom_gender.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public function up()
$accounts = DB::table('accounts')->select('id')->get();
foreach ($accounts as $account) {
$user = DB::table('users')->select('locale')->where('account_id', $account->id)->first();

if (! $user) {
continue;
}
\App::setLocale($user->locale);

$male = DB::table('genders')->insertGetId(['account_id' => $account->id, 'name' => trans('app.gender_male')]);
Expand Down
11 changes: 11 additions & 0 deletions tests/Unit/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,15 @@ public function test_it_gets_fluid_layout()
$user->getFluidLayout()
);
}

public function test_it_gets_the_locale()
{
$user = new User;
$user->locale = 'en';

$this->assertEquals(
'en',
$user->locale
);
}
}