Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webprofile-jwg2024
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Siti Aisah
webprofile-jwg2024
Commits
c0b6ddf3
Commit
c0b6ddf3
authored
Jan 12, 2020
by
Aan Choesni Herlingga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
translate en page
parent
f47c9885
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
128 additions
and
8 deletions
+128
-8
app/Http/Controllers/Webprofile/Backend/CategoryController.php
+1
-1
app/Http/Controllers/Webprofile/Backend/PageController.php
+40
-4
app/Http/Controllers/Webprofile/Backend/PostController.php
+1
-1
app/Models/Webprofile/En/Pages.php
+16
-0
app/Models/Webprofile/Pages.php
+6
-0
app/Repositories/Webprofile/En/PagesRepository.php
+22
-0
app/Repositories/Webprofile/PagesRepository.php
+7
-1
resources/views/webprofile/backend/pages/edit.blade.php
+35
-1
No files found.
app/Http/Controllers/Webprofile/Backend/CategoryController.php
View file @
c0b6ddf3
...
...
@@ -132,7 +132,7 @@ class CategoryController extends Controller
{
$dataEn
[
'name'
]
=
$data
[
'name_en'
];
$this
->
repo
->
update
(
$dataEn
,
$category
->
rEn
);
$this
->
repo
En
->
update
(
$dataEn
,
$category
->
rEn
);
}
/**
...
...
app/Http/Controllers/Webprofile/Backend/PageController.php
View file @
c0b6ddf3
...
...
@@ -5,15 +5,24 @@ namespace App\Http\Controllers\Webprofile\Backend;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
App\Models\Webprofile\Categories
;
use
App\Repositories\Webprofile\En\PagesRepository
as
EnPagesRepository
;
use
App\Repositories\Webprofile\PagesRepository
;
use
Statickidz\GoogleTranslate
;
class
PageController
extends
Controller
{
private
$repo
;
private
$repoEn
;
public
function
__construct
(
PagesRepository
$repo
)
{
private
$SOURCE
=
'id'
;
private
$TARGET
=
'en'
;
public
function
__construct
(
PagesRepository
$repo
,
EnPagesRepository
$repoEn
){
$this
->
repo
=
$repo
;
$this
->
repoEn
=
$repoEn
;
}
/**
* Display a listing of the resource.
...
...
@@ -56,11 +65,27 @@ class PageController extends Controller
{
$data
=
$request
->
except
(
'_token'
);
$this
->
repo
->
store
(
$data
);
$save
=
$this
->
repo
->
store
(
$data
);
// save translate
$this
->
createEn
(
$data
,
$save
);
return
redirect
()
->
route
(
'pages.index'
);
}
private
function
createEn
(
$data
,
$page
)
{
$trans
=
new
GoogleTranslate
();
$title
=
$trans
->
translate
(
$this
->
SOURCE
,
$this
->
TARGET
,
$data
[
'title'
]);
$content
=
$trans
->
translate
(
$this
->
SOURCE
,
$this
->
TARGET
,
strip_tags
(
$data
[
'content'
]));
$dataEn
[
'page_id'
]
=
$page
->
id
;
$dataEn
[
'title'
]
=
$title
;
$dataEn
[
'content'
]
=
$content
;
$this
->
repoEn
->
store
(
$dataEn
);
}
/**
* Display the specified resource.
*
...
...
@@ -100,14 +125,25 @@ class PageController extends Controller
*/
public
function
update
(
Request
$request
,
$id
)
{
$data
=
$request
->
except
([
'_token'
,
'id'
]);
$data
=
$request
->
except
([
'_token'
,
'id'
,
'title_en'
,
'content_en'
]);
$dataEn
=
$request
->
except
([
'_token'
,
'id'
]);
$page
=
$this
->
repo
->
findId
(
$id
);
$edit
=
$this
->
repo
->
update
(
$data
,
$page
);
$this
->
updateEn
(
$dataEn
,
$page
);
return
redirect
()
->
route
(
'pages.index'
);
}
public
function
updateEn
(
$data
,
$page
)
{
$dataEn
[
'title'
]
=
$data
[
'title_en'
];
$dataEn
[
'content'
]
=
$data
[
'content_en'
];
$this
->
repoEn
->
update
(
$dataEn
,
$page
->
rEn
);
}
/**
* Remove the specified resource from storage.
*
...
...
app/Http/Controllers/Webprofile/Backend/PostController.php
View file @
c0b6ddf3
...
...
@@ -148,7 +148,7 @@ class PostController extends Controller
$dataEn
[
'title'
]
=
$data
[
'title_en'
];
$dataEn
[
'content'
]
=
$data
[
'content_en'
];
$this
->
repo
->
update
(
$dataEn
,
$post
->
rEn
);
$this
->
repo
En
->
update
(
$dataEn
,
$post
->
rEn
);
}
/**
...
...
app/Models/Webprofile/En/Pages.php
0 → 100644
View file @
c0b6ddf3
<?php
namespace
App\Models\Webprofile\En
;
use
App\Http\Traits\UuidTrait
;
use
Illuminate\Database\Eloquent\Model
;
class
Pages
extends
Model
{
use
UuidTrait
;
public
$incrementing
=
false
;
protected
$table
=
'swp_pages_en'
;
protected
$guarded
=
[];
}
app/Models/Webprofile/Pages.php
View file @
c0b6ddf3
...
...
@@ -5,6 +5,7 @@ namespace App\Models\Webprofile;
use
App\Http\Traits\UuidTrait
;
use
Illuminate\Database\Eloquent\Model
;
use
App\Models\Webprofile\Categories
;
use
App\Models\Webprofile\En\Pages
as
EnPages
;
class
Pages
extends
Model
{
...
...
@@ -14,4 +15,9 @@ class Pages extends Model
protected
$table
=
'swp_pages'
;
protected
$guarded
=
[];
public
function
rEn
()
{
return
$this
->
hasOne
(
EnPages
::
class
,
'page_id'
,
'id'
);
}
}
app/Repositories/Webprofile/En/PagesRepository.php
0 → 100644
View file @
c0b6ddf3
<?php
namespace
App\Repositories\Webprofile\En
;
use
App\Models\Webprofile\En\Pages
;
use
App\Repositories\Repository
;
use
Illuminate\Database\Eloquent\Model
;
class
PagesRepository
extends
Repository
{
public
function
__construct
(
Pages
$model
)
{
$this
->
model
=
$model
;
}
public
function
get
()
{
}
public
function
paginate
()
{
}
}
app/Repositories/Webprofile/PagesRepository.php
View file @
c0b6ddf3
...
...
@@ -49,7 +49,13 @@ class PagesRepository extends Repository
return
$str
;
})
->
rawColumns
([
'action'
,
'sum'
])
->
addColumn
(
'title'
,
function
(
$row
)
{
$str
=
$row
->
title
.
'<br>'
;
$str
.=
'<i style="color: blue;">'
.
$row
->
rEn
->
title
.
'</i>'
;
return
$str
;
})
->
rawColumns
([
'action'
,
'sum'
,
'title'
])
->
make
(
true
);
}
}
resources/views/webprofile/backend/pages/edit.blade.php
View file @
c0b6ddf3
...
...
@@ -30,10 +30,13 @@
</div>
<div class="
panel
-
body
">
<div class="
row
">
<div style="
padding
:
10
px
10
px
10
px
10
px
;
font
-
weight
:
bold
;
font
-
size
:
14
pt
;
">
Bahasa Indonesia
</div>
<div class="
col
-
md
-
12
">
<div class="
form
-
group
@
if
(
$errors
->
has
(
'title'
))
has
-
error
@
endif
">
<div class="
col
-
md
-
12
">
{{ Form::text('title', old('title'), array('class' => 'form-control', 'placeholder'=>
app('translator')->getFromJson
('label.title'), 'style'=>'font-size: 14pt;')) }}
{{ Form::text('title', old('title'), array('class' => 'form-control', 'placeholder'=>
trans
('label.title'), 'style'=>'font-size: 14pt;')) }}
@if (
$errors->has
('title'))
<label id="
login
-
error
" class="
error
" for="
login
">
{
{$errors->first('title')}
}
</label>
@endif
...
...
@@ -45,6 +48,34 @@
{{ Form::textarea('content', null, array('id'=>'content')) }}
</div>
</div>
</div>
<div class="
row
">
<div style="
padding
:
10
px
10
px
10
px
10
px
;
font
-
weight
:
bold
;
font
-
size
:
14
pt
;
">
English Language
</div>
<div class="
col
-
md
-
12
">
<div class="
form
-
group
@
if
(
$errors
->
has
(
'title'
))
has
-
error
@
endif
">
<div class="
col
-
md
-
12
">
@if(
$data->rEn
)
{{ Form::text('title_en',
$data->rEn
->title, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }}
@else
{{ Form::text('title_en', null, array('class' => 'form-control', 'placeholder'=>trans('label.title'), 'style'=>'font-size: 14pt;')) }}
@endif
@if (
$errors->has
('title'))
<label id="
login
-
error
" class="
error
" for="
login
">
{
{$errors->first('title')}
}
</label>
@endif
</div>
</div>
</div>
<div class="
col
-
md
-
12
">
<div class="
block
">
@if (
$data->rEn
)
{{ Form::textarea('content_en',
$data->rEn
->content, array('id'=>'content_en')) }}
@else
{{ Form::textarea('content_en', null, array('id'=>'content_en')) }}
@endif
</div>
</div>
</div>
</div>
</div>
...
...
@@ -83,6 +114,9 @@
$('#content').summernote({
height: 400
});
$('#content_en').summernote({
height: 400
});
});
$('#categories').select2();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment