Commit 825e3be2 by Aan Choesni Herlingga

implement auto translate

parent d0939915
...@@ -147,7 +147,7 @@ class InformationController extends Controller ...@@ -147,7 +147,7 @@ class InformationController extends Controller
$dataEn['title'] = $data['title_en']; $dataEn['title'] = $data['title_en'];
$dataEn['content'] = $data['content_en']; $dataEn['content'] = $data['content_en'];
$this->repoEn->update($dataEn, $information->rEn); $this->repoEn->update($dataEn, $information);
} }
/** /**
......
...@@ -143,7 +143,7 @@ class PageController extends Controller ...@@ -143,7 +143,7 @@ class PageController extends Controller
$dataEn['title'] = $data['title_en']; $dataEn['title'] = $data['title_en'];
$dataEn['content'] = $data['content_en']; $dataEn['content'] = $data['content_en'];
$this->repoEn->update($dataEn, $page->rEn); $this->repoEn->update($dataEn, $page);
} }
/** /**
......
...@@ -150,7 +150,7 @@ class PostController extends Controller ...@@ -150,7 +150,7 @@ class PostController extends Controller
$dataEn['title'] = $data['title_en']; $dataEn['title'] = $data['title_en'];
$dataEn['content'] = $data['content_en']; $dataEn['content'] = $data['content_en'];
$this->repoEn->update($dataEn, $post->rEn); $this->repoEn->update($dataEn, $post);
} }
/** /**
......
...@@ -16,7 +16,15 @@ class InformationRepository extends Repository ...@@ -16,7 +16,15 @@ class InformationRepository extends Repository
public function get() public function get()
{ {
} }
public function paginate() public function paginate()
{ {
} }
public function update($data, $information)
{
return $this->model->updateOrCreate([
'information_id' => $information->id,
], $data);
}
} }
...@@ -4,7 +4,6 @@ namespace App\Repositories\Webprofile\En; ...@@ -4,7 +4,6 @@ namespace App\Repositories\Webprofile\En;
use App\Models\Webprofile\En\Pages; use App\Models\Webprofile\En\Pages;
use App\Repositories\Repository; use App\Repositories\Repository;
use Illuminate\Database\Eloquent\Model;
class PagesRepository extends Repository class PagesRepository extends Repository
{ {
...@@ -16,7 +15,15 @@ class PagesRepository extends Repository ...@@ -16,7 +15,15 @@ class PagesRepository extends Repository
public function get() public function get()
{ {
} }
public function paginate() public function paginate()
{ {
} }
public function update($data, $page)
{
return $this->model->updateOrCreate([
'page_id' => $page->id,
], $data);
}
} }
...@@ -12,6 +12,17 @@ class PostRepository extends Repository ...@@ -12,6 +12,17 @@ class PostRepository extends Repository
$this->model = $model; $this->model = $model;
} }
public function get(){} public function get()
public function paginate(){} {
}
public function paginate()
{
}
public function update($data, $post)
{
return $this->model->updateOrCreate([
'post_id' => $post->id,
], $data);
}
} }
...@@ -58,7 +58,9 @@ class InformationRepository extends Repository ...@@ -58,7 +58,9 @@ class InformationRepository extends Repository
}) })
->addColumn('title', function ($row) { ->addColumn('title', function ($row) {
$str = $row->title . '<br>'; $str = $row->title . '<br>';
$str .= '<i style="color: blue;">' . $row->rEn->title . '</i>'; if ($row->rEn) {
$str .= '<i style="color: blue;">' . $row->rEn->title . '</i>';
}
return $str; return $str;
}) })
......
...@@ -51,7 +51,10 @@ class PagesRepository extends Repository ...@@ -51,7 +51,10 @@ class PagesRepository extends Repository
}) })
->addColumn('title', function ($row) { ->addColumn('title', function ($row) {
$str = $row->title . '<br>'; $str = $row->title . '<br>';
$str .= '<i style="color: blue;">' . $row->rEn->title . '</i>';
if ($row->rEn) {
$str .= '<i style="color: blue;">' . $row->rEn->title . '</i>';
}
return $str; return $str;
}) })
......
...@@ -91,7 +91,9 @@ class PostRepository extends Repository ...@@ -91,7 +91,9 @@ class PostRepository extends Repository
}) })
->addColumn('title', function ($row) { ->addColumn('title', function ($row) {
$str = $row->title . '<br>'; $str = $row->title . '<br>';
$str .= '<i style="color: blue;">' . $row->rEn['title'] . '</i>'; if ($row->rEn) {
$str .= '<i style="color: blue;">' . $row->rEn['title'] . '</i>';
}
return $str; return $str;
}) })
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<div class="form-group @if ($errors->has('title')) has-error @endif"> <div class="form-group @if ($errors->has('title')) has-error @endif">
<div class="col-md-12"> <div class="col-md-12">
@if($data->rEn) @if($data->rEn)
{{ Form::text('title_en', $data->rEn->title, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }} {{ Form::text('title_en', $data->rEn ? $data->rEn->title : null, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }}
@else @else
{{ Form::text('title_en', null, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }} {{ Form::text('title_en', null, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }}
@endif @endif
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="block"> <div class="block">
@if ($data->rEn) @if ($data->rEn)
{{ Form::textarea('content_en', $data->rEn->content, array('id'=>'content_en')) }} {{ Form::textarea('content_en', $data->rEn ? $data->rEn->content : null, array('id'=>'content_en')) }}
@else @else
{{ Form::textarea('content_en', null, array('id'=>'content_en')) }} {{ Form::textarea('content_en', null, array('id'=>'content_en')) }}
@endif @endif
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<div class="form-group @if ($errors->has('title')) has-error @endif"> <div class="form-group @if ($errors->has('title')) has-error @endif">
<div class="col-md-12"> <div class="col-md-12">
@if($data->rEn) @if($data->rEn)
{{ Form::text('title_en', $data->rEn->title, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }} {{ Form::text('title_en', $data->rEn ? $data->rEn->title : null, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }}
@else @else
{{ Form::text('title_en', null, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }} {{ Form::text('title_en', null, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }}
@endif @endif
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="block"> <div class="block">
@if ($data->rEn) @if ($data->rEn)
{{ Form::textarea('content_en', $data->rEn->content, array('id'=>'content_en')) }} {{ Form::textarea('content_en', $data->rEn ? $data->rEn->content : null, array('id'=>'content_en')) }}
@else @else
{{ Form::textarea('content_en', null, array('id'=>'content_en')) }} {{ Form::textarea('content_en', null, array('id'=>'content_en')) }}
@endif @endif
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group @if ($errors->has('title')) has-error @endif"> <div class="form-group @if ($errors->has('title')) has-error @endif">
<div class="col-md-12"> <div class="col-md-12">
{{ Form::text('title_en', $data->rEn->title, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;')) }} {{ Form::text('title_en', $data->rEn ? $data->rEn->title : null, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;')) }}
@if ($errors->has('title')) @if ($errors->has('title'))
<label id="login-error" class="error" for="login">{{$errors->first('title')}}</label> <label id="login-error" class="error" for="login">{{$errors->first('title')}}</label>
@endif @endif
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<div class="block"> <div class="block">
{{ Form::textarea('content_en', $data->rEn->content, array('id'=>'content_en')) }} {{ Form::textarea('content_en', $data->rEn ? $data->rEn->content : null, array('id'=>'content_en')) }}
</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