updating user and language models
This commit is contained in:
parent
fdba9f1ae7
commit
64d4d326b7
@ -42,18 +42,18 @@ class HandleInertiaRequests extends Middleware
|
||||
*/
|
||||
public function share(Request $request): array
|
||||
{
|
||||
$localeFields = ['locale', 'iso_code', 'name', 'localized_name'];
|
||||
$localeFields = ['locale_name', 'iso_code', 'name', 'localized_name'];
|
||||
$currentLocale = $request->session()->get('locale', null);
|
||||
if (is_null($currentLocale)) {
|
||||
$currentLocale = Language::where(['locale' => 'en', 'iso_code' => 'en_US'])->get($localeFields)[0]->toArray();
|
||||
$currentLocale = Language::where(['locale_name' => 'en', 'iso_code' => 'en_US'])->get($localeFields)[0]->toArray();
|
||||
$request->session()->put('locale', [
|
||||
'locale' => $currentLocale['locale'],
|
||||
'locale_name' => $currentLocale['locale_name'],
|
||||
'iso_code' => $currentLocale['iso_code'],
|
||||
'name' => $currentLocale['name'],
|
||||
'localized_name' => $currentLocale['localized_name'],
|
||||
]);
|
||||
}
|
||||
$localeFilePath = base_path("lang/{$currentLocale['locale']}.json");
|
||||
$localeFilePath = base_path("lang/{$currentLocale['locale_name']}.json");
|
||||
|
||||
$notifications = [];
|
||||
$notificationsCount = count($notifications);
|
||||
|
@ -7,18 +7,20 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Language extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
/** @var string */
|
||||
protected $table = 'languages';
|
||||
|
||||
/** @var array<int,string> */
|
||||
protected $fillable = [
|
||||
'locale',
|
||||
'locale_name',
|
||||
'iso_code',
|
||||
'name',
|
||||
'localized_name',
|
||||
|
@ -32,7 +32,7 @@ class UserFactory extends Factory
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'timezone_name' => $this->faker->timezone(),
|
||||
'timezone_name' => Language::all()->random()->id,
|
||||
'language_id' => Language::all()->random()->id,
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
|
@ -15,7 +15,7 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('languages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('locale')->index();
|
||||
$table->string('locale_name')->index();
|
||||
$table->string('iso_code')->unique();
|
||||
$table->string('name');
|
||||
$table->string('localized_name');
|
||||
|
Loading…
x
Reference in New Issue
Block a user