Open Stelikas opened 2 years ago
Just writing the sample code here:
$service = Service::find($id);
$locale = app()->getLocale();
$service = $service->translate($locale);
$service->category_id = $data['service']['category_id'];
$service->related_articles = $data['service']['related_articles'];
$service->title = $data['service']['title'];
$service->slug = $data['service']['slug'];
$service->introtext = $data['service']['introtext'];
$service->image = $data['service']['image'];
$service->author = $data['service']['author'];
$service->approved_by = $data['service']['approved_by'];
$service->average_cost = $data['service']['average_cost'];
$service->duration = $data['service']['duration'];
$service->frequency = $data['service']['frequency'];
$service->meta_title = $data['service']['meta_title'];
$service->meta_description = $data['service']['meta_description'];
$service->published = $data['service']['published'];
$service->inherit_pricetable = $data['service']['inherit_pricetable'];
$service->calendar_service = $data['service']['calendar_service'];
$service->save();
Also, i just noticed it doesn't save all of the fields, in the database the only field that is required is the title which is filled but it displays the error i wrote above at the issue, also some of the fields above are not translatable but i don't think that's an issue, based on the documentation if the field is not translatable it will make changes directly to the model itself.
In voyager admin it works fine, but I'm creating a custom admin dashboard and the above code doesn't work for some reason.
Looks like because some of the fields were null the error was displayed, although they are not required in the database, Voyager returns this error without displaying for which field it is talking about, still it does not update non translatable fields like the documentation says that it will make changes directly to the model itself
, i hope someone knows something on this topic because i will have to do a lot of writing for such a simple thing(Get translated model->save translated model with translations->get non translatable model->save non translatable fields)
.
Laravel version
5.8
PHP version
7.1
Voyager version
1.2
Database
MySQL 5.7
Description
It displays an error on post request when trying to translate a model.
Steps to reproduce
Expected behavior
Even though the data is saved, it returns an error on AJAX post request.
Screenshots
No response
Additional context
No response