Add multiple translation to translation table

SOLVED

Hi everyone, I've been working on a Laravel project and encountered a perplexing issue that I haven't been able to resolve, despite consulting with ChatGPT for assistance. I'm hoping someone here might be able to shed some light on it.

Problem:
I'm trying to add new translations to a translations table in my Laravel application. However, when I attempt to insert a new translation, I consistently receive the following error:

Illuminate\Database\QueryException
PHP 8.2.4
10.38.2
SQLSTATE[HY000]: General error: 1364 Field 'locale' doesn't have a default value
INSERT INTO translations (key, updated_at, created_at) VALUES (123, 2023-12-30 20:01:10, 2023-12-30 20:01:10)

Expected Behavior:
My intention is for the system to insert one row per language into the database, all with the same key, but with different locale values.

Current Observation:
The locale value doesn't seem to be getting inserted, and I can't figure out why. This is leading to a failure due to the lack of a default value for the locale field.

Relevant Code Snippet:

Here's the Eloquent model for Translation:
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Translation extends Model
{
use HasFactory;

protected $fillable = [
'locale',
'key',
'value',
];
}

TranslationResource : https://pastebin.com/4wMKuvgZ
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Was this page helpful?