Closed ArtMin96 closed 4 years ago
Hey,
the easiest approach should be something like this:
view
@foreach(app(\Astrotomic\Translatable\Locales::class)->all() as $locale)
<input type="text" name="title[{{ $locale }}]"/>
<input type="text" name="description[{{ $locale }}]"/>
@endforeach
rules
return RuleFactory::make([
'%title%' => 'required|string',
'%description%' => 'required|string',
'image' => 'file|max:5000|mimes:png,jpg,jpeg,gif',
]);
That's it - with this you should get title
and description as an array with the locales as key and translations as value in your request which the packages
fill()method can handle so you just have to do
$model->fill($request->validated())`.
The rules returned by the rule factory will mirror this as an array with the title
and description
listed for every locale in dot.notation - like title.en
.
https://docs.astrotomic.info/laravel-translatable/package/validation-rule-factory
Thanks for the quick response. I tried the option you suggested but again some problems arise. In your package, everything is good. I have another problem right now. Maybe I'll try again later and use your answer. I close the question.
Hi.
There are fields that are subject to cloning and should be validated and display messages for each field. Can you help me to figure out this?
edit.blade.php
PageContentRequest.php
PageContentController.php