0

I got used to request to validate before entering the API side function itself, but recently, when I moved the controller function to services then, the error message became like the below sample.

{
    "message": "validation.min.string",
    "errors": {
        "password": [
            "validation.min.string"
        ]
    }
}

But when I use the same way build in the new project, the error message show as usual as below

{
    "message": "The name must only contain letters.",
    "errors": {
        "name": [
            "The name must only contain letters."
        ]
    }
 }

I found that I had added an en language file under res resources\lang\en, which caused this issue, so may I know how I can change back to this version without removing the en file? Thanks

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Dirty Rex
  • 13
  • 4
  • 1
    Why do you want `lang` folder insde the `resources` ? – xenooooo Jan 12 '23 at 03:25
  • @xenooooo that's the old method from my senior ><, he use this place to do the matching things. – Dirty Rex Jan 12 '23 at 03:27
  • why not just copy the `lang` folder to the root folder ? – xenooooo Jan 12 '23 at 03:30
  • If I use the `lang` in `root` file, am I still able to use `trans()` function to get the data from `en` file? – Dirty Rex Jan 12 '23 at 03:35
  • 1
    no, depends what laravel version you are using... Larave 9+ will look for `lang` on the root, not the previous ones... Could you share what that language file looks like? – matiaslauriti Jan 12 '23 at 03:46
  • @matiaslauriti just now I tested my side the trans function still working my side languages format like ` return [ "key"=> [ "item"=> "translate_item" ] ];` – Dirty Rex Jan 12 '23 at 03:49

0 Answers0