Commit cc6756fb by Bagus Pambudi

bug fix update auto translate dan manual

parent ec13963f
......@@ -332,8 +332,8 @@ class PostController extends Controller
*/
public function update(Request $request, $id)
{
$data = $request->except(['_token', 'id', 'title_en', 'content_en', 'title_de', 'content_de', 'title_sa', 'content_sa', 'title_zh', 'content_zh']);
$dataEn = $request->except(['_token', 'id']);
$data = $request->except(['_token','manual', 'id', 'title_en', 'content_en', 'title_de', 'content_de', 'title_sa', 'content_sa', 'title_zh', 'content_zh']);
$dataEn = $request->except(['_token', 'id', 'manual']);
array_key_exists('post_status', $data) ? $data['post_status'] = 1 : $data['post_status'] = 0;
array_key_exists('cover_status', $data) ? $data['cover_status'] = 1 : $data['cover_status'] = 0;
......@@ -350,21 +350,28 @@ class PostController extends Controller
$this->repo->update($img, $post);
}
// dd($data);
$this->updateEn($dataEn, $post);
$this->updateDe($dataEn, $post);
$this->updateSa($dataEn, $post);
$this->updateZh($dataEn, $post);
$this->updateEn($dataEn, $post, $request->manual);
$this->updateDe($dataEn, $post, $request->manual);
$this->updateSa($dataEn, $post, $request->manual);
$this->updateZh($dataEn, $post, $request->manual);
return redirect()->route('posts.index');
}
public function updateEn($data, $post)
public function updateEn($data, $post, $manual)
{
if($manual=1){
// dd($manual);
if($manual==1){
$dataEn['title'] = $data['title_en'];
$dataEn['content'] = $data['content_en'];
}
else{
if (strip_tags($data['content']) == null) {
$data['content'] = 'kosong';
}
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']);
$content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content']));
......@@ -376,13 +383,18 @@ class PostController extends Controller
$this->repoEn->update($dataEn, $post);
}
public function updateDe($data, $post)
public function updateDe($data, $post, $manual)
{
if($manual=1){
if($manual==1){
$dataDe['title'] = $data['title_de'];
$dataDe['content'] = $data['content_de'];
}
else{
if (strip_tags($data['content']) == null) {
$data['content'] = 'kosong';
}
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETDE, $data['title']);
$content = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['content']));
......@@ -392,13 +404,18 @@ class PostController extends Controller
$this->repoDe->update($dataDe, $post);
}
public function updateSa($data, $post)
public function updateSa($data, $post, $manual)
{
if($manual=1){
if($manual==1){
$dataSa['title'] = $data['title_sa'];
$dataSa['content'] = $data['content_sa'];
}
else{
if (strip_tags($data['content']) == null) {
$data['content'] = 'kosong';
}
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETSA, $data['title']);
$content = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['content']));
......@@ -408,13 +425,17 @@ class PostController extends Controller
$this->repoSa->update($dataSa, $post);
}
public function updateZh($data, $post)
public function updateZh($data, $post, $manual)
{
if($manual=1){
if($manual==1){
$dataZh['title'] = $data['title_zh'];
$dataZh['content'] = $data['content_zh'];
}
else{
if (strip_tags($data['content']) == null) {
$data['content'] = 'kosong';
}
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETZH, $data['title']);
$content = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['content']));
......
......@@ -56,6 +56,7 @@
<div class="col-md-12">
<div class="block">
{{ Form::textarea('content', null, array('id'=>'content')) }}
{{ Form::hidden('manual', $manual, array('id'=>'manual')) }}
</div>
</div>
</div>
......
......@@ -56,6 +56,7 @@
<div class="col-md-12">
<div class="block">
{{ Form::textarea('content', null, array('id'=>'content')) }}
{{ Form::hidden('manual', $manual, array('id'=>'manual')) }}
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment