Commit 04aaebc8 by Triyah Fatmawati

Mengubah fitur update agar otomatis translate semua bahasa

parent f876b7ce
......@@ -323,7 +323,7 @@ class PostController extends Controller
$post = $this->repo->findId($id, ['rEn', 'rDe', 'rSa', 'rZh']);
$edit = $this->repo->update($data, $post);
// dd($post);
$tipe = 'thumbnail';
if ($request->hasFile($tipe)) {
$img[$tipe] = $post->id.'.'.$request->file($tipe)->guessClientExtension();
......@@ -331,7 +331,7 @@ class PostController extends Controller
$this->repo->upload($img[$tipe], $request, $tipe);
$this->repo->update($img, $post);
}
// dd($data);
$this->updateEn($dataEn, $post);
$this->updateDe($dataEn, $post);
$this->updateSa($dataEn, $post);
......@@ -342,32 +342,45 @@ class PostController extends Controller
public function updateEn($data, $post)
{
$dataEn['title'] = $data['title_en'];
$dataEn['content'] = $data['content_en'];
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']);
$content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content']));
// dd($title);
$dataEn['title'] = $title;
$dataEn['content'] = $content;
// dd($dataEn['title']);
$this->repoEn->update($dataEn, $post);
}
public function updateDe($data, $post)
{
$dataDe['title'] = $data['title_de'];
$dataDe['content'] = $data['content_de'];
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETDE, $data['title']);
$content = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['content']));
$dataDe['title'] = $title;
$dataDe['content'] = $content;
$this->repoDe->update($dataDe, $post);
}
public function updateSa($data, $post)
{
$dataSa['title'] = $data['title_sa'];
$dataSa['content'] = $data['content_sa'];
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETSA, $data['title']);
$content = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['content']));
$dataSa['title'] = $title;
$dataSa['content'] = $content;
$this->repoSa->update($dataSa, $post);
}
public function updateZh($data, $post)
{
$dataZh['title'] = $data['title_zh'];
$dataZh['content'] = $data['content_zh'];
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETZH, $data['title']);
$content = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['content']));
$dataZh['title'] = $title;
$dataZh['content'] = $content;
$this->repoZh->update($dataZh, $post);
}
......
......@@ -35,7 +35,9 @@ class PostRepository extends Repository
return DataTables::of($data)
->addIndexColumn()
->addColumn('action', function ($row) {
$btn = '<a href="'.url('/webprofile/posts/'.$row->id.'/edit').'" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="'.trans('label.edit').'" class="edit btn btn-warning btn-round btn-sm edit">'.trans('label.edit').'</a>';
$btn = '<a href="'.url('/webprofile/posts/'.$row->id.'/edit').'" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="'.trans('label.editsemuabahasa').'" class="edit btn btn-warning btn-round btn-sm edit">'.trans('label.editsemuabahasa').'</a>';
// $btn = $btn.' <a href="'.url('/webprofile/posts/'.$row->id.'/editPerBahasa').'" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="'.trans('label.edittiapbahasa').'" class="edit btn btn-warning btn-round btn-sm edit">'.trans('label.edittiapbahasa').'</a>';
$btn = $btn.' <a href="javascript:void(0)" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="'.trans('label.delete').'" class="btn btn-danger btn-round btn-sm delete">'.trans('label.delete').'</a>';
......
......@@ -3,7 +3,8 @@
return [
'dashboard' => 'Dashboard',
'create' => 'Create',
'edit' => 'Edit',
'editsemuabahasa' => 'Edit',
'edittiapbahasa' => 'Edit Each Language',
'update' => 'Update',
'delete' => 'Delete',
'save' => 'Save',
......
......@@ -3,7 +3,8 @@
return [
'dashboard' => 'Beranda',
'create' => 'Tambah',
'edit' => 'Ubah',
'editsemuabahasa' => 'Edit',
'edittiapbahasa' => 'Edit Per Bahasa',
'update' => 'Update',
'delete' => 'Hapus',
'save' => 'Simpan',
......
......@@ -59,7 +59,8 @@
</div>
</div>
</div>
<div class="tabs">
{{-- <div class="tabs">
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#inggris" role="tab" data-toggle="tab" aria-expanded="true">Inggris</a></li>
<li class=""><a href="#jerman" role="tab" data-toggle="tab" aria-expanded="false">Jerman</a></li>
......@@ -148,7 +149,7 @@
</div>
</div>
</div>
</div>
</div> --}}
</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