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
922f08b6
Commit
922f08b6
authored
Jan 12, 2020
by
Aan Choesni Herlingga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
translate en information
parent
6106797a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
128 additions
and
7 deletions
+128
-7
app/Http/Controllers/Webprofile/Backend/InformationController.php
+41
-5
app/Http/Controllers/Webprofile/Backend/PageController.php
+1
-1
app/Models/Webprofile/En/Information.php
+16
-0
app/Models/Webprofile/Information.php
+6
-0
app/Repositories/Webprofile/En/InformationRepository.php
+22
-0
app/Repositories/Webprofile/InformationRepository.php
+7
-1
database/migrations/2020_01_12_143401_create_informations_en_table.php
+1
-0
resources/views/webprofile/backend/informations/edit.blade.php
+34
-0
No files found.
app/Http/Controllers/Webprofile/Backend/InformationController.php
View file @
922f08b6
...
...
@@ -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\InformationRepository
as
EnInformationRepository
;
use
App\Repositories\Webprofile\InformationRepository
;
use
Statickidz\GoogleTranslate
;
class
InformationController
extends
Controller
{
private
$repo
;
private
$repoEn
;
public
function
__construct
(
InformationRepository
$repo
)
{
private
$SOURCE
=
'id'
;
private
$TARGET
=
'en'
;
public
function
__construct
(
InformationRepository
$repo
,
EnInformationRepository
$repoEn
){
$this
->
repo
=
$repo
;
$this
->
repoEn
=
$repoEn
;
}
/**
* Display a listing of the resource.
...
...
@@ -58,11 +67,27 @@ class InformationController extends Controller
array_key_exists
(
'info_status'
,
$data
)
?
$data
[
'info_status'
]
=
1
:
$data
[
'info_status'
]
=
0
;
$this
->
repo
->
store
(
$data
);
$save
=
$this
->
repo
->
store
(
$data
);
// save translate
$this
->
createEn
(
$data
,
$save
);
return
redirect
()
->
route
(
'informations.index'
);
}
private
function
createEn
(
$data
,
$information
)
{
$trans
=
new
GoogleTranslate
();
$title
=
$trans
->
translate
(
$this
->
SOURCE
,
$this
->
TARGET
,
$data
[
'title'
]);
$content
=
$trans
->
translate
(
$this
->
SOURCE
,
$this
->
TARGET
,
strip_tags
(
$data
[
'content'
]));
$dataEn
[
'information_id'
]
=
$information
->
id
;
$dataEn
[
'title'
]
=
$title
;
$dataEn
[
'content'
]
=
$content
;
$this
->
repoEn
->
store
(
$dataEn
);
}
/**
* Display the specified resource.
*
...
...
@@ -102,16 +127,27 @@ class InformationController 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'
]);
array_key_exists
(
'info_status'
,
$data
)
?
$data
[
'info_status'
]
=
1
:
$data
[
'info_status'
]
=
0
;
$information
=
$this
->
repo
->
findId
(
$id
);
$information
=
$this
->
repo
->
findId
(
$id
,
[
'rEn'
]
);
$edit
=
$this
->
repo
->
update
(
$data
,
$information
);
$this
->
updateEn
(
$dataEn
,
$information
);
return
redirect
()
->
route
(
'informations.index'
);
}
public
function
updateEn
(
$data
,
$information
)
{
$dataEn
[
'title'
]
=
$data
[
'title_en'
];
$dataEn
[
'content'
]
=
$data
[
'content_en'
];
$this
->
repoEn
->
update
(
$dataEn
,
$information
->
rEn
);
}
/**
* Remove the specified resource from storage.
*
...
...
app/Http/Controllers/Webprofile/Backend/PageController.php
View file @
922f08b6
...
...
@@ -128,7 +128,7 @@ class PageController extends Controller
$data
=
$request
->
except
([
'_token'
,
'id'
,
'title_en'
,
'content_en'
]);
$dataEn
=
$request
->
except
([
'_token'
,
'id'
]);
$page
=
$this
->
repo
->
findId
(
$id
);
$page
=
$this
->
repo
->
findId
(
$id
,
[
'rEn'
]
);
$edit
=
$this
->
repo
->
update
(
$data
,
$page
);
$this
->
updateEn
(
$dataEn
,
$page
);
...
...
app/Models/Webprofile/En/Information.php
0 → 100644
View file @
922f08b6
<?php
namespace
App\Models\Webprofile\En
;
use
App\Http\Traits\UuidTrait
;
use
Illuminate\Database\Eloquent\Model
;
class
Information
extends
Model
{
use
UuidTrait
;
public
$incrementing
=
false
;
protected
$table
=
'swp_informations_en'
;
protected
$guarded
=
[];
}
app/Models/Webprofile/Information.php
View file @
922f08b6
...
...
@@ -3,6 +3,7 @@
namespace
App\Models\Webprofile
;
use
App\Http\Traits\UuidTrait
;
use
App\Models\Webprofile\En\Information
as
EnInformation
;
use
Illuminate\Database\Eloquent\Model
;
class
Information
extends
Model
...
...
@@ -13,4 +14,9 @@ class Information extends Model
protected
$table
=
'swp_informations'
;
protected
$guarded
=
[];
public
function
rEn
()
{
return
$this
->
hasOne
(
EnInformation
::
class
,
'information_id'
,
'id'
);
}
}
app/Repositories/Webprofile/En/InformationRepository.php
0 → 100644
View file @
922f08b6
<?php
namespace
App\Repositories\Webprofile\En
;
use
App\Models\Webprofile\En\Information
;
use
App\Repositories\Repository
;
use
Illuminate\Database\Eloquent\Model
;
class
InformationRepository
extends
Repository
{
public
function
__construct
(
Information
$model
)
{
$this
->
model
=
$model
;
}
public
function
get
()
{
}
public
function
paginate
()
{
}
}
app/Repositories/Webprofile/InformationRepository.php
View file @
922f08b6
...
...
@@ -56,7 +56,13 @@ class InformationRepository extends Repository
}
return
$str
;
})
->
rawColumns
([
'action'
,
'status'
,
'date'
])
->
addColumn
(
'title'
,
function
(
$row
)
{
$str
=
$row
->
title
.
'<br>'
;
$str
.=
'<i style="color: blue;">'
.
$row
->
rEn
->
title
.
'</i>'
;
return
$str
;
})
->
rawColumns
([
'action'
,
'status'
,
'date'
,
'title'
])
->
make
(
true
);
}
}
database/migrations/2020_01_12_143401_create_informations_en_table.php
View file @
922f08b6
...
...
@@ -20,6 +20,7 @@ class CreateInformationsEnTable extends Migration
$table
->
text
(
'content'
)
->
nullable
();
$table
->
string
(
'userid_created'
,
36
)
->
nullable
();
$table
->
string
(
'userid_updated'
,
36
)
->
nullable
();
$table
->
timestamps
();
});
}
...
...
resources/views/webprofile/backend/informations/edit.blade.php
View file @
922f08b6
...
...
@@ -30,6 +30,9 @@
</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
">
...
...
@@ -46,6 +49,34 @@
</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>
</div>
...
...
@@ -121,6 +152,9 @@
$('#content').summernote({
height: 400
});
$('#content_en').summernote({
height: 400
});
});
</script>
@stop
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