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
35af22e0
Commit
35af22e0
authored
Jan 11, 2020
by
Aan Choesni Herlingga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
translate en category post
parent
0e3beec8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
6 deletions
+108
-6
app/Http/Controllers/Webprofile/Backend/CategoryController.php
+37
-5
app/Models/Webprofile/Categories.php
+6
-0
app/Models/Webprofile/En/Categories.php
+16
-0
app/Repositories/Webprofile/CategoryRepository.php
+9
-1
app/Repositories/Webprofile/En/CategoryRepository.php
+21
-0
resources/views/webprofile/backend/categories/edit.blade.php
+19
-0
No files found.
app/Http/Controllers/Webprofile/Backend/CategoryController.php
View file @
35af22e0
...
@@ -5,14 +5,23 @@ namespace App\Http\Controllers\Webprofile\Backend;
...
@@ -5,14 +5,23 @@ namespace App\Http\Controllers\Webprofile\Backend;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
App\Repositories\Webprofile\CategoryRepository
;
use
App\Repositories\Webprofile\CategoryRepository
;
use
App\Repositories\Webprofile\En\CategoryRepository
as
EnCategoryRepository
;
use
Statickidz\GoogleTranslate
;
class
CategoryController
extends
Controller
class
CategoryController
extends
Controller
{
{
private
$repo
;
private
$repo
;
private
$repoEn
;
public
function
__construct
(
CategoryRepository
$repo
)
private
$SOURCE
=
'id'
;
{
private
$TARGET
=
'en'
;
public
function
__construct
(
CategoryRepository
$repo
,
EnCategoryRepository
$repoEn
){
$this
->
repo
=
$repo
;
$this
->
repo
=
$repo
;
$this
->
repoEn
=
$repoEn
;
}
}
/**
/**
* Display a listing of the resource.
* Display a listing of the resource.
...
@@ -51,11 +60,24 @@ class CategoryController extends Controller
...
@@ -51,11 +60,24 @@ class CategoryController extends Controller
array_key_exists
(
'is_active'
,
$data
)
?
$data
[
'is_active'
]
=
1
:
$data
[
'is_active'
]
=
0
;
array_key_exists
(
'is_active'
,
$data
)
?
$data
[
'is_active'
]
=
1
:
$data
[
'is_active'
]
=
0
;
$this
->
repo
->
store
(
$data
);
$category
=
$this
->
repo
->
store
(
$data
);
$this
->
createEn
(
$data
,
$category
);
return
redirect
()
->
route
(
'category.index'
);
return
redirect
()
->
route
(
'category.index'
);
}
}
private
function
createEn
(
$data
,
$category
)
{
$trans
=
new
GoogleTranslate
();
$name
=
$trans
->
translate
(
$this
->
SOURCE
,
$this
->
TARGET
,
$data
[
'name'
]);
$dataEn
[
'category_id'
]
=
$category
->
id
;
$dataEn
[
'name'
]
=
$name
;
$this
->
repoEn
->
store
(
$dataEn
);
}
/**
/**
* Display the specified resource.
* Display the specified resource.
*
*
...
@@ -93,16 +115,26 @@ class CategoryController extends Controller
...
@@ -93,16 +115,26 @@ class CategoryController extends Controller
*/
*/
public
function
update
(
Request
$request
,
$id
)
public
function
update
(
Request
$request
,
$id
)
{
{
$data
=
$request
->
except
([
'_token'
,
'id'
]);
$data
=
$request
->
except
([
'_token'
,
'id'
,
'name_en'
]);
$dataEn
=
$request
->
except
([
'_token'
,
'id'
]);
array_key_exists
(
'is_active'
,
$data
)
?
$data
[
'is_active'
]
=
1
:
$data
[
'is_active'
]
=
0
;
array_key_exists
(
'is_active'
,
$data
)
?
$data
[
'is_active'
]
=
1
:
$data
[
'is_active'
]
=
0
;
$category
=
$this
->
repo
->
findId
(
$id
);
$category
=
$this
->
repo
->
findId
(
$id
,
[
'rEn'
]
);
$edit
=
$this
->
repo
->
update
(
$data
,
$category
);
$edit
=
$this
->
repo
->
update
(
$data
,
$category
);
$this
->
updateEn
(
$dataEn
,
$category
);
return
redirect
()
->
route
(
'category.index'
);
return
redirect
()
->
route
(
'category.index'
);
}
}
public
function
updateEn
(
$data
,
$category
)
{
$dataEn
[
'name'
]
=
$data
[
'name_en'
];
$this
->
repo
->
update
(
$dataEn
,
$category
->
rEn
);
}
/**
/**
* Remove the specified resource from storage.
* Remove the specified resource from storage.
*
*
...
...
app/Models/Webprofile/Categories.php
View file @
35af22e0
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
App\Models\Webprofile
;
namespace
App\Models\Webprofile
;
use
App\Http\Traits\UuidTrait
;
use
App\Http\Traits\UuidTrait
;
use
App\Models\Webprofile\En\Categories
as
EnCategories
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
Categories
extends
Model
class
Categories
extends
Model
...
@@ -18,4 +19,9 @@ class Categories extends Model
...
@@ -18,4 +19,9 @@ class Categories extends Model
{
{
return
$this
->
hasMany
(
Posts
::
class
,
'id'
,
'categories'
);
return
$this
->
hasMany
(
Posts
::
class
,
'id'
,
'categories'
);
}
}
public
function
rEn
()
{
return
$this
->
hasOne
(
EnCategories
::
class
,
'category_id'
,
'id'
);
}
}
}
app/Models/Webprofile/En/Categories.php
0 → 100644
View file @
35af22e0
<?php
namespace
App\Models\Webprofile\En
;
use
App\Http\Traits\UuidTrait
;
use
Illuminate\Database\Eloquent\Model
;
class
Categories
extends
Model
{
use
UuidTrait
;
public
$incrementing
=
false
;
protected
$table
=
'swp_categories_en'
;
protected
$guarded
=
[];
}
app/Repositories/Webprofile/CategoryRepository.php
View file @
35af22e0
...
@@ -51,7 +51,15 @@ class CategoryRepository extends Repository
...
@@ -51,7 +51,15 @@ class CategoryRepository extends Repository
}
}
return
$str
;
return
$str
;
})
})
->
rawColumns
([
'action'
,
'status'
])
->
addColumn
(
'name'
,
function
(
$row
)
{
$str
=
$row
->
name
.
'<br>'
;
if
(
$row
->
rEn
)
{
$str
.=
'<i style="color: blue;">'
.
$row
->
rEn
->
name
.
'</i>'
;
}
return
$str
;
})
->
rawColumns
([
'action'
,
'status'
,
'name'
])
->
make
(
true
);
->
make
(
true
);
}
}
}
}
app/Repositories/Webprofile/En/CategoryRepository.php
0 → 100644
View file @
35af22e0
<?php
namespace
App\Repositories\Webprofile\En
;
use
App\Models\Webprofile\En\Categories
;
use
App\Repositories\Repository
;
class
CategoryRepository
extends
Repository
{
public
function
__construct
(
Categories
$model
)
{
$this
->
model
=
$model
;
}
public
function
get
()
{
}
public
function
paginate
()
{
}
}
resources/views/webprofile/backend/categories/edit.blade.php
View file @
35af22e0
...
@@ -21,6 +21,9 @@
...
@@ -21,6 +21,9 @@
</div>
</div>
<div class="
panel
-
body
">
<div class="
panel
-
body
">
<div class="
row
">
<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="
col
-
md
-
12
">
<div class="
form
-
group
@
if
(
$errors
->
has
(
'name'
))
has
-
error
@
endif
">
<div class="
form
-
group
@
if
(
$errors
->
has
(
'name'
))
has
-
error
@
endif
">
<label class="
col
-
md
-
2
control
-
label
">Kategori</label>
<label class="
col
-
md
-
2
control
-
label
">Kategori</label>
...
@@ -31,6 +34,22 @@
...
@@ -31,6 +34,22 @@
@endif
@endif
</div>
</div>
</div>
</div>
</div>
<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
(
'name_en'
))
has
-
error
@
endif
">
<label class="
col
-
md
-
2
control
-
label
">Category</label>
<div class="
col
-
md
-
10
">
{{ Form::text('name_en',
$data->rEn
->name, array('class' => 'form-control')) }}
@if (
$errors->has
('name_en'))
<label id="
login
-
error
" class="
error
" for="
login
">
{
{$errors->first('name_en')}
}
</label>
@endif
</div>
</div>
</div>
<div class="
col
-
md
-
12
">
<div class="
form
-
group
" style="
padding
-
top
:
10
px
;
">
<div class="
form
-
group
" style="
padding
-
top
:
10
px
;
">
<label class="
col
-
md
-
2
control
-
label
">Status</label>
<label class="
col
-
md
-
2
control
-
label
">Status</label>
<div class="
col
-
md
-
10
">
<div class="
col
-
md
-
10
">
...
...
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