Commit ec13963f by Bagus Pambudi

edit post manual dan auto translate

parent 04aaebc8
......@@ -295,15 +295,33 @@ class PostController extends Controller
$setting = webprofilesetting();
$data = $this->repo->findId($id, ['rEn', 'rDe', 'rSa', 'rZh']);
$categories = Categories::pluck('name', 'id');
$manual=0;
$data = [
'data' => $data,
'categories' => $categories,
'setting' => $setting,
'manual'=> $manual,
];
return view('webprofile.backend.posts.edit', $data)->withTitle(trans('feature.edit_post'));
}
public function editPerBahasa($id)
{
$setting = webprofilesetting();
$data = $this->repo->findId($id, ['rEn', 'rDe', 'rSa', 'rZh']);
$categories = Categories::pluck('name', 'id');
$manual=1;
$data = [
'data' => $data,
'categories' => $categories,
'setting' => $setting,
'manual' => $manual,
];
return view('webprofile.backend.posts.edit_per_bahasa', $data)->withTitle(trans('feature.edit_post'));
}
/**
* Update the specified resource in storage.
......@@ -342,6 +360,11 @@ class PostController extends Controller
public function updateEn($data, $post)
{
if($manual=1){
$dataEn['title'] = $data['title_en'];
$dataEn['content'] = $data['content_en'];
}
else{
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title']);
$content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['content']));
......@@ -349,39 +372,55 @@ class PostController extends Controller
$dataEn['title'] = $title;
$dataEn['content'] = $content;
// dd($dataEn['title']);
}
$this->repoEn->update($dataEn, $post);
}
public function updateDe($data, $post)
{
if($manual=1){
$dataDe['title'] = $data['title_de'];
$dataDe['content'] = $data['content_de'];
}
else{
$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)
{
if($manual=1){
$dataSa['title'] = $data['title_sa'];
$dataSa['content'] = $data['content_sa'];
}
else{
$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)
{
if($manual=1){
$dataZh['title'] = $data['title_zh'];
$dataZh['content'] = $data['content_zh'];
}
else{
$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);
}
......
......@@ -37,7 +37,7 @@ class PostRepository extends Repository
->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.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="'.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>';
......
......@@ -15,6 +15,7 @@ Route::group(['middleware' => 'auth'], function () {
Route::group(['middleware' => 'role:admin|laman'], function () {
Route::group(['namespace' => 'Webprofile\Backend', 'prefix' => 'webprofile'], function () {
Route::resource('category', 'CategoryController');
Route::get('posts/{id}/editperbahasa', 'PostController@editperbahasa');
Route::resource('posts', 'PostController');
Route::resource('pages', 'PageController');
Route::resource('agendas', 'AgendaController');
......
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