Commit 04aaebc8 by Triyah Fatmawati

Mengubah fitur update agar otomatis translate semua bahasa

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