Commit d289c28a by Bagus Pambudi

layout multi bahasa

parent 94bc48d1
......@@ -5,15 +5,40 @@ namespace App\Http\Controllers\Webprofile\Backend;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Repositories\Webprofile\DesignRepository;
use App\Repositories\Webprofile\De\DesignRepository as DeDesignRepository;
use App\Repositories\Webprofile\En\DesignRepository as EnDesignRepository;
use App\Repositories\Webprofile\Sa\DesignRepository as SaDesignRepository;
use App\Repositories\Webprofile\Zh\DesignRepository as ZhDesignRepository;
use Statickidz\GoogleTranslate;
use Crypt;
class LayoutController extends Controller
{
private $repo;
private $repoEn;
private $repoDe;
private $repoSa;
private $repoZh;
public function __construct(DesignRepository $repo)
private $SOURCE = 'id';
private $TARGET = 'en';
private $TARGETDE = 'de';
private $TARGETSA = 'ar';
private $TARGETZH = 'zh';
public function __construct(
DesignRepository $repo,
EnDesignRepository $repoEn,
DeDesignRepository $repoDe,
SaDesignRepository $repoSa,
ZhDesignRepository $repoZh
)
{
$this->repo = $repo;
$this->repoEn = $repoEn;
$this->repoDe = $repoDe;
$this->repoSa = $repoSa;
$this->repoZh = $repoZh;
}
/**
......@@ -24,6 +49,7 @@ class LayoutController extends Controller
public function index()
{
$layouts = $this->repo->get();
$data = [
'layouts' => $layouts,
......@@ -53,11 +79,91 @@ class LayoutController extends Controller
$data = $request->except('_token');
array_key_exists('title_show', $data) ? $data['title_show'] = 1 : $data['title_show'] = 0;
$this->repo->store($data);
$save=$this->repo->store($data);
if (webprofilesetting()['auto_translate'] == 1) {
// save translate
$this->createEn($data, $save);
$this->createDe($data, $save);
$this->createSa($data, $save);
$this->createZh($data, $save);
}
return redirect()->route('layouts.index');
}
private function createEn($data, $layouts)
{
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGET, $data['title_design']);
if (strip_tags($data['value_design']) == null) {
$data['value_design'] = 'kosong';
}
$content = $trans->translate($this->SOURCE, $this->TARGET, strip_tags($data['value_design']));
$dataEn['design_id'] = $layouts->id;
$dataEn['title_design'] = $title;
$dataEn['value_design'] = $content;
$this->repoEn->store($dataEn);
}
private function createDe($data, $layouts)
{
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETDE, $data['title_design']);
if (strip_tags($data['value_design']) == null) {
$data['value_design'] = 'kosong';
}
$content = $trans->translate($this->SOURCE, $this->TARGETDE, strip_tags($data['value_design']));
$dataDe['design_id'] = $layouts->id;
$dataDe['title_design'] = $title;
$dataDe['value_design'] = $content;
$this->repoDe->store($dataDe);
}
private function createSa($data, $layouts)
{
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETSA, $data['title_design']);
if (strip_tags($data['value_design']) == null) {
$data['value_design'] = 'kosong';
}
$content = $trans->translate($this->SOURCE, $this->TARGETSA, strip_tags($data['value_design']));
$dataSa['design_id'] = $layouts->id;
$dataSa['title_design'] = $title;
$dataSa['value_design'] = $content;
$this->repoSa->store($dataSa);
}
private function createZh($data, $layouts)
{
$trans = new GoogleTranslate();
$title = $trans->translate($this->SOURCE, $this->TARGETZH, $data['title_design']);
if (strip_tags($data['value_design']) == null) {
$data['value_design'] = 'kosong';
}
$content = $trans->translate($this->SOURCE, $this->TARGETZH, strip_tags($data['value_design']));
$dataZh['design_id'] = $layouts->id;
$dataZh['title_design'] = $title;
$dataZh['value_design'] = $content;
$this->repoZh->store($dataZh);
}
/**
* Display the specified resource.
*
......@@ -81,7 +187,7 @@ class LayoutController extends Controller
*/
public function edit($id)
{
$layout = $this->repo->findId(Crypt::decrypt($id));
$layout = $this->repo->findId(Crypt::decrypt($id), ['rEn', 'rDe', 'rSa', 'rZh']);
$data = [
'data' => $layout,
......@@ -99,14 +205,51 @@ class LayoutController extends Controller
*/
public function update(Request $request, $id)
{
$data = $request->except(['_token', 'id']);
$data = $request->except(['_token', 'id', 'title_design_en', 'content_en', 'title_design_de', 'content_de', 'title_design_sa', 'content_sa', 'title_design_zh', 'content_zh']);
array_key_exists('title_show', $data) ? $data['title_show'] = 1 : $data['title_show'] = 0;
$dataEn = $request->except(['_token', 'id']);
$layout = $this->repo->findId($id);
$edit = $this->repo->update($data, $layout);
$this->updateEn($dataEn, $layout);
$this->updateDe($dataEn, $layout);
$this->updateSa($dataEn, $layout);
$this->updateZh($dataEn, $layout);
return redirect()->route('layouts.index');
}
public function updateEn($data, $layout)
{
$dataEn['title_design'] = $data['title_design_en'];
$dataEn['value_design'] = $data['content_en'];
$this->repoEn->update($dataEn, $layout);
}
public function updateDe($data, $layout)
{
$dataDe['title_design'] = $data['title_design_de'];
$dataDe['value_design'] = $data['content_de'];
$this->repoDe->update($dataDe, $layout);
}
public function updateSa($data, $layout)
{
$dataSa['title_design'] = $data['title_design_sa'];
$dataSa['value_design'] = $data['content_sa'];
$this->repoSa->update($dataSa, $layout);
}
public function updateZh($data, $layout)
{
$dataZh['title_design'] = $data['title_design_zh'];
$dataZh['value_design'] = $data['content_zh'];
$this->repoZh->update($dataZh, $layout);
}
/**
* Remove the specified resource from storage.
......@@ -116,8 +259,23 @@ class LayoutController extends Controller
*/
public function destroy($id)
{
$data = $this->repo->findId(Crypt::decrypt($id));
$data = $this->repo->findId(Crypt::decrypt($id),['rEn', 'rDe', 'rSa', 'rZh']);
$this->repo->destroy($data);
if ($data->rEn) {
$this->repoEn->destroy($data->rEn);
}
if ($data->rDe) {
$this->repoDe->destroy($data->rDe);
}
if ($data->rSa) {
$this->repoSa->destroy($data->rSa);
}
if ($data->rZh) {
$this->repoZh->destroy($data->rZh);
}
return redirect()->route('layouts.index');
}
......
......@@ -86,10 +86,10 @@ class FrontController extends Controller
$slider = Slider::where('is_active', '1')->orderby('created_at', 'desc')->get();
$menu = Menu::with(['rEn'])->orderby('urutan', 'asc')->get();
$gallery = Gallery::where('is_active', '1')->orderBy('created_at', 'asc')->limit('4')->get();
$quote = Design::where('name_design', 'quote')->get();
$quote = Design::with(['rEn'])->where('name_design', 'quote')->get();
$widget_right = Design::where('name_design', 'widget_right')->orderBy('urutan', 'ASC')->get();
$widget_left = Design::where('name_design', 'widget_left')->orderBy('urutan', 'ASC')->get();
$body = Design::where('name_design', 'body')->get();
$body = Design::with(['rEn'])->where('name_design', 'body')->get();
$footer = Design::where('name_design', 'like', '%footer_row%')->get();
$data = [
......@@ -120,10 +120,10 @@ class FrontController extends Controller
$slider = Slider::where('is_active', '1')->orderby('created_at', 'desc')->get();
$menu = Menu::with(['rDe'])->orderby('urutan', 'asc')->get();
$gallery = Gallery::where('is_active', '1')->orderBy('created_at', 'asc')->limit('4')->get();
$quote = Design::where('name_design', 'quote')->get();
$quote = Design::with(['rDe'])->where('name_design', 'quote')->get();
$widget_right = Design::where('name_design', 'widget_right')->orderBy('urutan', 'ASC')->get();
$widget_left = Design::where('name_design', 'widget_left')->orderBy('urutan', 'ASC')->get();
$body = Design::where('name_design', 'body')->get();
$body = Design::with(['rDe'])->where('name_design', 'body')->get();
$footer = Design::where('name_design', 'like', '%footer_row%')->get();
$data = [
......@@ -154,10 +154,10 @@ class FrontController extends Controller
$slider = Slider::where('is_active', '1')->orderby('created_at', 'desc')->get();
$menu = Menu::with(['rSa'])->orderby('urutan', 'asc')->get();
$gallery = Gallery::where('is_active', '1')->orderBy('created_at', 'asc')->limit('4')->get();
$quote = Design::where('name_design', 'quote')->get();
$quote = Design::with(['rSa'])->where('name_design', 'quote')->get();
$widget_right = Design::where('name_design', 'widget_right')->orderBy('urutan', 'ASC')->get();
$widget_left = Design::where('name_design', 'widget_left')->orderBy('urutan', 'ASC')->get();
$body = Design::where('name_design', 'body')->get();
$body = Design::with(['rSa'])->where('name_design', 'body')->get();
$footer = Design::where('name_design', 'like', '%footer_row%')->get();
$data = [
......@@ -188,10 +188,10 @@ class FrontController extends Controller
$slider = Slider::where('is_active', '1')->orderby('created_at', 'desc')->get();
$menu = Menu::with(['rZh'])->orderby('urutan', 'asc')->get();
$gallery = Gallery::where('is_active', '1')->orderBy('created_at', 'asc')->limit('4')->get();
$quote = Design::where('name_design', 'quote')->get();
$quote = Design::with(['rZh'])->where('name_design', 'quote')->get();
$widget_right = Design::where('name_design', 'widget_right')->orderBy('urutan', 'ASC')->get();
$widget_left = Design::where('name_design', 'widget_left')->orderBy('urutan', 'ASC')->get();
$body = Design::where('name_design', 'body')->get();
$body = Design::with(['rZh'])->where('name_design', 'body')->get();
$footer = Design::where('name_design', 'like', '%footer_row%')->get();
$data = [
......
......@@ -3,6 +3,10 @@
namespace App\Models\Webprofile;
use App\Http\Traits\UuidTrait;
use App\Models\Webprofile\De\Design as DeDesign;
use App\Models\Webprofile\En\Design as EnDesign;
use App\Models\Webprofile\Sa\Design as SaDesign;
use App\Models\Webprofile\Zh\Design as ZhDesign;
use Illuminate\Database\Eloquent\Model;
class Design extends Model
......@@ -13,4 +17,24 @@ class Design extends Model
protected $table = 'swp_design';
protected $guarded = [];
public function rEn()
{
return $this->hasOne(EnDesign::class, 'design_id', 'id');
}
public function rDe()
{
return $this->hasOne(DeDesign::class, 'design_id', 'id');
}
public function rSa()
{
return $this->hasOne(SaDesign::class, 'design_id', 'id');
}
public function rZh()
{
return $this->hasOne(ZhDesign::class, 'design_id', 'id');
}
}
......@@ -10,7 +10,7 @@ class Design extends Model
use UuidTrait;
public $incrementing = false;
protected $table = 'swp_design_de';
protected $table = 'swp_design_sa';
protected $guarded = [];
}
<?php
namespace App\Repositories\Webprofile\De;
use App\Models\Webprofile\De\Design;
use App\Repositories\Repository;
class DesignRepository extends Repository
{
public function __construct(Design $model)
{
$this->model = $model;
}
public function get()
{
}
public function paginate()
{
}
public function update($data, $design)
{
return $this->model->updateOrCreate([
'design_id' => $design->id,
], $data);
}
}
<?php
namespace App\Repositories\Webprofile\En;
use App\Models\Webprofile\En\Design;
use App\Repositories\Repository;
class DesignRepository extends Repository
{
public function __construct(Design $model)
{
$this->model = $model;
}
public function get()
{
}
public function paginate()
{
}
public function update($data, $design)
{
return $this->model->updateOrCreate([
'design_id' => $design->id,
], $data);
}
}
<?php
namespace App\Repositories\Webprofile\Sa;
use App\Models\Webprofile\Sa\Design;
use App\Repositories\Repository;
class DesignRepository extends Repository
{
public function __construct(Design $model)
{
$this->model = $model;
}
public function get()
{
}
public function paginate()
{
}
public function update($data, $design)
{
return $this->model->updateOrCreate([
'design_id' => $design->id,
], $data);
}
}
<?php
namespace App\Repositories\Webprofile\Zh;
use App\Models\Webprofile\Zh\Design;
use App\Repositories\Repository;
class DesignRepository extends Repository
{
public function __construct(Design $model)
{
$this->model = $model;
}
public function get()
{
}
public function paginate()
{
}
public function update($data, $design)
{
return $this->model->updateOrCreate([
'design_id' => $design->id,
], $data);
}
}
......@@ -31,6 +31,9 @@
<div class="panel-body">
<div class="row">
{{ Form::text('name_design', $data->name_design, ['style'=>'display:none;']) }}
<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
Bahasa Indonesia
</div>
<div class="col-md-12">
<div class="form-group @if ($errors->has('title_design')) has-error @endif">
<div class="col-md-11">
......@@ -53,6 +56,96 @@
</div>
</div>
</div>
<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>
<li class=""><a href="#arab" role="tab" data-toggle="tab" aria-expanded="false">Arab</a></li>
<li class=""><a href="#cina" role="tab" data-toggle="tab" aria-expanded="false">Cina</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="inggris">
<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
English Language
</div>
<div class="col-md-12">
<div class="form-group @if ($errors->has('title_design')) has-error @endif">
<div class="col-md-12">
{{ Form::text('title_design_en', $data->rEn ? $data->rEn->title_design : null, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;', 'required')) }}
@if ($errors->has('title_design'))
<label id="login-error" class="error" for="login">{{$errors->first('title_design')}}</label>
@endif
</div>
</div>
</div>
<div class="col-md-12">
<div class="block">
{{ Form::textarea('content_en', $data->rEn ? $data->rEn->value_design : null, array('id'=>'content_en')) }}
</div>
</div>
</div>
<div class="tab-pane" id="jerman">
<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
deutsche Sprache
</div>
<div class="col-md-12">
<div class="form-group @if ($errors->has('title_design')) has-error @endif">
<div class="col-md-12">
{{ Form::text('title_design_de', $data->rDe ? $data->rDe->title_design : null, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;', 'required')) }}
@if ($errors->has('title_design'))
<label id="login-error" class="error" for="login">{{$errors->first('title_design')}}</label>
@endif
</div>
</div>
</div>
<div class="col-md-12">
<div class="block">
{{ Form::textarea('content_de', $data->rDe ? $data->rDe->value_design : null, array('id'=>'content_de')) }}
</div>
</div>
</div>
<div class="tab-pane" id="arab">
<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
اللغة الألمانية
</div>
<div class="col-md-12">
<div class="form-group @if ($errors->has('title_design')) has-error @endif">
<div class="col-md-12">
{{ Form::text('title_design_sa', $data->rSa ? $data->rSa->title_design : null, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;', 'required')) }}
@if ($errors->has('title_design'))
<label id="login-error" class="error" for="login">{{$errors->first('title_design')}}</label>
@endif
</div>
</div>
</div>
<div class="col-md-12">
<div class="block">
{{ Form::textarea('content_sa', $data->rSa ? $data->rSa->value_design : null, array('id'=>'content_sa')) }}
</div>
</div>
</div>
<div class="tab-pane" id="cina">
<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
中文
</div>
<div class="col-md-12">
<div class="form-group @if ($errors->has('title_design')) has-error @endif">
<div class="col-md-12">
{{ Form::text('title_design_zh', $data->rZh ? $data->rZh->title_design : null, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;', 'required')) }}
@if ($errors->has('title_design'))
<label id="login-error" class="error" for="login">{{$errors->first('title_design')}}</label>
@endif
</div>
</div>
</div>
<div class="col-md-12">
<div class="block">
{{ Form::textarea('content_zh', $data->rZh ? $data->rZh->value_design : null, array('id'=>'content_zh')) }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
......@@ -74,4 +167,26 @@
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('backend/js/plugins/summernote/summernote.js') !!}
<script type="text/javascript">
$(document).ready(function() {
$('#content').summernote({
height: 350
});
$('#content_en').summernote({
height: 350
});
$('#content_de').summernote({
height: 350
});
$('#content_sa').summernote({
height: 350
});
$('#content_zh').summernote({
height: 350
});
});
</script>
@stop
\ No newline at end of file
......@@ -186,12 +186,16 @@
@foreach ($body as $value)
<div class="container">
<div class="general-title">
<h2>{!! $value->title_design !!}</h2>
@if($value->rSa)
<h2>{!! $value->rSa->title_design !!}</h2>
<hr>
@endif
</div>
</div>
<!-- end container -->
{!! $value->value_design !!}
@if($value->rSa)
{!! $value->rSa->value_design !!}
@endif
@endforeach
<div class="clearfix"></div>
</section>
......@@ -280,8 +284,10 @@
<div class="calloutbox-full-mini nocontainer">
<div class="long-twitter">
<p class="lead">
{!! $value->value_design !!}
<div style="text-align: center; font-size: 14pt;">{!! $value->title_design !!}</div>
@if($value->rSa)
{!! $value->rSa->value_design !!}
<div style="text-align: center; font-size: 14pt;">{!! $value->rSa->title_design !!}</div>
@endif
</p>
</div>
</div>
......
......@@ -186,12 +186,16 @@
@foreach ($body as $value)
<div class="container">
<div class="general-title">
<h2>{!! $value->title_design !!}</h2>
@if($value->rDe)
<h2>{!! $value->rDe->title_design !!}</h2>
<hr>
@endif
</div>
</div>
<!-- end container -->
{!! $value->value_design !!}
@if($value->rDe)
{!! $value->rDe->value_design !!}
@endif
@endforeach
<div class="clearfix"></div>
</section>
......@@ -280,8 +284,10 @@
<div class="calloutbox-full-mini nocontainer">
<div class="long-twitter">
<p class="lead">
{!! $value->value_design !!}
<div style="text-align: center; font-size: 14pt;">{!! $value->title_design !!}</div>
@if($value->rDe)
{!! $value->rDe->value_design !!}
<div style="text-align: center; font-size: 14pt;">{!! $value->rDe->title_design !!}</div>
@endif
</p>
</div>
</div>
......
......@@ -186,12 +186,16 @@
@foreach ($body as $value)
<div class="container">
<div class="general-title">
<h2>{!! $value->title_design !!}</h2>
@if($value->rEn)
<h2>{!! $value->rEn->title_design !!}</h2>
<hr>
@endif
</div>
</div>
<!-- end container -->
@if($value->rEn)
{!! $value->value_design !!}
@endif
@endforeach
<div class="clearfix"></div>
</section>
......@@ -280,8 +284,10 @@
<div class="calloutbox-full-mini nocontainer">
<div class="long-twitter">
<p class="lead">
{!! $value->value_design !!}
<div style="text-align: center; font-size: 14pt;">{!! $value->title_design !!}</div>
@if($value->rEn)
{!! $value->rEn->value_design !!}
<div style="text-align: center; font-size: 14pt;">{!! $value->rEn->title_design !!}</div>
@endif
</p>
</div>
</div>
......
......@@ -26,6 +26,7 @@
div.yamm-content{
max-height: 400px;
max-width: 1200px;
overflow-x: scroll;
overflow-y: scroll;
......
......@@ -60,3 +60,24 @@
@endif
@endif
@endforeach
<li class="dropdown yamm-fw"><a href="#" data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-search search-btn"></i> <div class="arrow-up"></div></a>
<ul class="dropdown-menu" style="text-transform: capitalize;">
<form action="#">
<div class="input-group input-large col-sm-12">
<script>
(function() {
var cx = '015636097340515973415:j4b24ginvqk';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
</div>
</form>
</ul>
</li>
......@@ -186,12 +186,16 @@
@foreach ($body as $value)
<div class="container">
<div class="general-title">
<h2>{!! $value->title_design !!}</h2>
@if($value->rZh)
<h2>{!! $value->rZh->title_design !!}</h2>
<hr>
@endif
</div>
</div>
<!-- end container -->
{!! $value->value_design !!}
@if($value->rZh)
{!! $value->rZh->value_design !!}
@endif
@endforeach
<div class="clearfix"></div>
</section>
......@@ -280,8 +284,10 @@
<div class="calloutbox-full-mini nocontainer">
<div class="long-twitter">
<p class="lead">
{!! $value->value_design !!}
<div style="text-align: center; font-size: 14pt;">{!! $value->title_design !!}</div>
@if($value->rZh)
{!! $value->rZh->value_design !!}
<div style="text-align: center; font-size: 14pt;">{!! $value->rZh->title_design !!}</div>
@endif
</p>
</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