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
e40dde27
Commit
e40dde27
authored
Mar 03, 2020
by
Aan Choesni Herlingga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix create menu from page
parent
c0d0728e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
22 deletions
+28
-22
app/Http/Controllers/Webprofile/Backend/MenuController.php
+25
-21
app/Models/Webprofile/Menu.php
+3
-1
No files found.
app/Http/Controllers/Webprofile/Backend/MenuController.php
View file @
e40dde27
...
@@ -7,7 +7,6 @@ use Illuminate\Http\Request;
...
@@ -7,7 +7,6 @@ use Illuminate\Http\Request;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
App\Models\Webprofile\Menu
;
use
App\Models\Webprofile\Menu
;
use
Validator
;
use
Validator
;
use
Uuid
;
use
Alert
;
use
Alert
;
use
App\Repositories\Webprofile\En\MenuRepository
;
use
App\Repositories\Webprofile\En\MenuRepository
;
use
Crypt
;
use
Crypt
;
...
@@ -32,7 +31,7 @@ class MenuController extends Controller
...
@@ -32,7 +31,7 @@ class MenuController extends Controller
public
function
index
()
public
function
index
()
{
{
$parent
=
Menu
::
where
(
'status'
,
'1'
)
->
whereNull
(
'url'
)
->
whereIn
(
'level'
,
[
1
,
2
])
->
pluck
(
'name'
,
'id'
);
$parent
=
Menu
::
where
(
'status'
,
'1'
)
->
whereNull
(
'url'
)
->
whereIn
(
'level'
,
[
1
,
2
])
->
pluck
(
'name'
,
'id'
);
$page
=
Pages
::
where
(
'post_status'
,
'1
'
)
->
pluck
(
'title'
,
'id'
);
$page
=
Pages
::
orderBy
(
'title'
,
'asc
'
)
->
pluck
(
'title'
,
'id'
);
$data
=
Menu
::
with
([
'rEn'
])
->
select
(
'id'
,
'parent'
,
'name'
,
'url'
,
'level'
,
'urutan'
)
->
orderby
(
'level'
,
'asc'
)
->
orderby
(
'urutan'
,
'asc'
)
->
get
();
$data
=
Menu
::
with
([
'rEn'
])
->
select
(
'id'
,
'parent'
,
'name'
,
'url'
,
'level'
,
'urutan'
)
->
orderby
(
'level'
,
'asc'
)
->
orderby
(
'urutan'
,
'asc'
)
->
get
();
$arr
=
$this
->
build_menu
();
$arr
=
$this
->
build_menu
();
...
@@ -56,7 +55,7 @@ class MenuController extends Controller
...
@@ -56,7 +55,7 @@ class MenuController extends Controller
if
(
$this
->
menu_has_child
(
$item
->
parent
))
{
if
(
$this
->
menu_has_child
(
$item
->
parent
))
{
$menu
[
$i
][
'child'
]
=
$this
->
menu_get_child
(
$item
->
id
);
$menu
[
$i
][
'child'
]
=
$this
->
menu_get_child
(
$item
->
id
);
}
}
$i
++
;
++
$i
;
}
}
return
$menu
;
return
$menu
;
...
@@ -89,7 +88,7 @@ class MenuController extends Controller
...
@@ -89,7 +88,7 @@ class MenuController extends Controller
if
(
$this
->
menu_has_child
(
$citem
->
parent
))
{
if
(
$this
->
menu_has_child
(
$citem
->
parent
))
{
$cmenu
[
$i
][
'child'
]
=
$this
->
menu_get_child
(
$citem
->
id
);
$cmenu
[
$i
][
'child'
]
=
$this
->
menu_get_child
(
$citem
->
id
);
}
}
$i
++
;
++
$i
;
}
}
return
$cmenu
;
return
$cmenu
;
...
@@ -99,10 +98,10 @@ class MenuController extends Controller
...
@@ -99,10 +98,10 @@ class MenuController extends Controller
{
{
$cur_menu
=
Menu
::
where
(
'id'
,
Crypt
::
decrypt
(
$id
))
->
first
();
$cur_menu
=
Menu
::
where
(
'id'
,
Crypt
::
decrypt
(
$id
))
->
first
();
if
(
$cur_menu
->
parentlevel
==
null
)
{
if
(
$cur_menu
->
parentlevel
==
null
)
{
$up_menu
=
Menu
::
where
(
'level'
,
$cur_menu
->
level
)
->
where
(
'urutan'
,
(
int
)
$cur_menu
->
urutan
-
1
)
->
first
();
$up_menu
=
Menu
::
where
(
'level'
,
$cur_menu
->
level
)
->
where
(
'urutan'
,
(
int
)
$cur_menu
->
urutan
-
1
)
->
first
();
}
}
if
(
$cur_menu
->
parentlevel
!=
null
)
{
if
(
$cur_menu
->
parentlevel
!=
null
)
{
$up_menu
=
Menu
::
where
(
'parent'
,
$cur_menu
->
parent
)
->
where
(
'level'
,
$cur_menu
->
level
)
->
where
(
'urutan'
,
(
int
)
$cur_menu
->
urutan
-
1
)
->
first
();
$up_menu
=
Menu
::
where
(
'parent'
,
$cur_menu
->
parent
)
->
where
(
'level'
,
$cur_menu
->
level
)
->
where
(
'urutan'
,
(
int
)
$cur_menu
->
urutan
-
1
)
->
first
();
}
}
Menu
::
where
(
'id'
,
Crypt
::
decrypt
(
$id
))
->
update
([
Menu
::
where
(
'id'
,
Crypt
::
decrypt
(
$id
))
->
update
([
...
@@ -112,7 +111,7 @@ class MenuController extends Controller
...
@@ -112,7 +111,7 @@ class MenuController extends Controller
]);
]);
Menu
::
where
(
'id'
,
$up_menu
->
id
)
->
update
([
Menu
::
where
(
'id'
,
$up_menu
->
id
)
->
update
([
'urutan'
=>
$up_menu
->
urutan
+
1
,
'urutan'
=>
$up_menu
->
urutan
+
1
,
'userid_created'
=>
Auth
::
user
()
->
name
,
'userid_created'
=>
Auth
::
user
()
->
name
,
'updated_at'
=>
date
(
'Y-m-d H:i:s'
),
'updated_at'
=>
date
(
'Y-m-d H:i:s'
),
]);
]);
...
@@ -124,10 +123,10 @@ class MenuController extends Controller
...
@@ -124,10 +123,10 @@ class MenuController extends Controller
{
{
$cur_menu
=
Menu
::
where
(
'id'
,
Crypt
::
decrypt
(
$id
))
->
first
();
$cur_menu
=
Menu
::
where
(
'id'
,
Crypt
::
decrypt
(
$id
))
->
first
();
if
(
$cur_menu
->
parentlevel
==
null
)
{
if
(
$cur_menu
->
parentlevel
==
null
)
{
$up_menu
=
Menu
::
where
(
'level'
,
$cur_menu
->
level
)
->
where
(
'urutan'
,
(
int
)
$cur_menu
->
urutan
+
1
)
->
first
();
$up_menu
=
Menu
::
where
(
'level'
,
$cur_menu
->
level
)
->
where
(
'urutan'
,
(
int
)
$cur_menu
->
urutan
+
1
)
->
first
();
}
}
if
(
$cur_menu
->
parentlevel
!=
null
)
{
if
(
$cur_menu
->
parentlevel
!=
null
)
{
$up_menu
=
Menu
::
where
(
'parent'
,
$cur_menu
->
parent
)
->
where
(
'level'
,
$cur_menu
->
level
)
->
where
(
'urutan'
,
(
int
)
$cur_menu
->
urutan
+
1
)
->
first
();
$up_menu
=
Menu
::
where
(
'parent'
,
$cur_menu
->
parent
)
->
where
(
'level'
,
$cur_menu
->
level
)
->
where
(
'urutan'
,
(
int
)
$cur_menu
->
urutan
+
1
)
->
first
();
}
}
Menu
::
where
(
'id'
,
Crypt
::
decrypt
(
$id
))
->
update
([
Menu
::
where
(
'id'
,
Crypt
::
decrypt
(
$id
))
->
update
([
...
@@ -137,7 +136,7 @@ class MenuController extends Controller
...
@@ -137,7 +136,7 @@ class MenuController extends Controller
]);
]);
Menu
::
where
(
'id'
,
$up_menu
->
id
)
->
update
([
Menu
::
where
(
'id'
,
$up_menu
->
id
)
->
update
([
'urutan'
=>
$up_menu
->
urutan
-
1
,
'urutan'
=>
$up_menu
->
urutan
-
1
,
'userid_created'
=>
Auth
::
user
()
->
name
,
'userid_created'
=>
Auth
::
user
()
->
name
,
'updated_at'
=>
date
(
'Y-m-d H:i:s'
),
'updated_at'
=>
date
(
'Y-m-d H:i:s'
),
]);
]);
...
@@ -152,13 +151,13 @@ class MenuController extends Controller
...
@@ -152,13 +151,13 @@ class MenuController extends Controller
*/
*/
public
function
create
()
public
function
create
()
{
{
//
}
}
/**
/**
* Store a newly created resource in storage.
* Store a newly created resource in storage.
*
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response
*/
*/
public
function
store
(
Request
$request
)
public
function
store
(
Request
$request
)
...
@@ -168,6 +167,7 @@ class MenuController extends Controller
...
@@ -168,6 +167,7 @@ class MenuController extends Controller
if
(
$validator
->
fails
())
{
if
(
$validator
->
fails
())
{
$errormessage
=
$validator
->
messages
();
$errormessage
=
$validator
->
messages
();
return
redirect
()
->
route
(
'menu.index'
)
return
redirect
()
->
route
(
'menu.index'
)
->
withErrors
(
$validator
)
->
withErrors
(
$validator
)
->
withInput
();
->
withInput
();
...
@@ -178,7 +178,7 @@ class MenuController extends Controller
...
@@ -178,7 +178,7 @@ class MenuController extends Controller
}
else
{
}
else
{
$getlevelparent
=
Menu
::
where
(
'id'
,
$request
->
input
(
'parent'
))
->
first
()
->
level
;
$getlevelparent
=
Menu
::
where
(
'id'
,
$request
->
input
(
'parent'
))
->
first
()
->
level
;
$parentlevel
=
$getlevelparent
;
$parentlevel
=
$getlevelparent
;
$level
=
(
int
)
$getlevelparent
+
1
;
$level
=
(
int
)
$getlevelparent
+
1
;
}
}
$urutan
=
Menu
::
where
(
'level'
,
$level
)
->
where
(
'parent'
,
$request
->
input
(
'parent'
))
->
max
(
'urutan'
);
$urutan
=
Menu
::
where
(
'level'
,
$level
)
->
where
(
'parent'
,
$request
->
input
(
'parent'
))
->
max
(
'urutan'
);
...
@@ -186,7 +186,7 @@ class MenuController extends Controller
...
@@ -186,7 +186,7 @@ class MenuController extends Controller
$data
[
'status'
]
=
1
;
$data
[
'status'
]
=
1
;
$data
[
'level'
]
=
$level
;
$data
[
'level'
]
=
$level
;
$data
[
'parentlevel'
]
=
$parentlevel
;
$data
[
'parentlevel'
]
=
$parentlevel
;
$data
[
'urutan'
]
=
$urutan
+
1
;
$data
[
'urutan'
]
=
$urutan
+
1
;
$data
[
'userid_created'
]
=
Auth
::
user
()
->
name
;
$data
[
'userid_created'
]
=
Auth
::
user
()
->
name
;
$data
[
'userid_updated'
]
=
Auth
::
user
()
->
name
;
$data
[
'userid_updated'
]
=
Auth
::
user
()
->
name
;
...
@@ -196,7 +196,8 @@ class MenuController extends Controller
...
@@ -196,7 +196,8 @@ class MenuController extends Controller
Alert
::
success
(
'Data berhasil disimpan'
)
->
persistent
(
'Ok'
);
Alert
::
success
(
'Data berhasil disimpan'
)
->
persistent
(
'Ok'
);
$successmessage
=
"Proses Tambah Menu Berhasil !!"
;
$successmessage
=
'Proses Tambah Menu Berhasil !!'
;
return
redirect
()
->
route
(
'menu.index'
)
->
with
(
'successMessage'
,
$successmessage
);
return
redirect
()
->
route
(
'menu.index'
)
->
with
(
'successMessage'
,
$successmessage
);
}
}
}
}
...
@@ -212,13 +213,14 @@ class MenuController extends Controller
...
@@ -212,13 +213,14 @@ class MenuController extends Controller
$this
->
repoEn
->
store
(
$dataEn
);
$this
->
repoEn
->
store
(
$dataEn
);
}
}
public
function
new
storepage
(
Request
$request
)
public
function
storepage
(
Request
$request
)
{
{
$data
=
$request
->
except
(
'_token'
);
$data
=
$request
->
except
(
'_token'
);
$validator
=
Validator
::
make
(
$data
,
Menu
::
$rules
,
Menu
::
$errormessage
);
$validator
=
Validator
::
make
(
$data
,
Menu
::
$rules
,
Menu
::
$errormessage
);
if
(
$validator
->
fails
())
{
if
(
$validator
->
fails
())
{
$errormessage
=
$validator
->
messages
();
$errormessage
=
$validator
->
messages
();
return
redirect
()
->
route
(
'menu.index'
)
return
redirect
()
->
route
(
'menu.index'
)
->
withErrors
(
$validator
)
->
withErrors
(
$validator
)
->
withInput
();
->
withInput
();
...
@@ -229,7 +231,7 @@ class MenuController extends Controller
...
@@ -229,7 +231,7 @@ class MenuController extends Controller
}
else
{
}
else
{
$getlevelparent
=
Menu
::
where
(
'id'
,
$request
->
input
(
'parentpage'
))
->
first
()
->
level
;
$getlevelparent
=
Menu
::
where
(
'id'
,
$request
->
input
(
'parentpage'
))
->
first
()
->
level
;
$parentlevel
=
$getlevelparent
;
$parentlevel
=
$getlevelparent
;
$level
=
(
int
)
$getlevelparent
+
1
;
$level
=
(
int
)
$getlevelparent
+
1
;
}
}
$urutan
=
Menu
::
where
(
'level'
,
$level
)
->
where
(
'parent'
,
$request
->
input
(
'parentpage'
))
->
max
(
'urutan'
);
$urutan
=
Menu
::
where
(
'level'
,
$level
)
->
where
(
'parent'
,
$request
->
input
(
'parentpage'
))
->
max
(
'urutan'
);
...
@@ -239,7 +241,7 @@ class MenuController extends Controller
...
@@ -239,7 +241,7 @@ class MenuController extends Controller
$data
[
'name'
]
=
$page
->
title
;
$data
[
'name'
]
=
$page
->
title
;
$data
[
'level'
]
=
$level
;
$data
[
'level'
]
=
$level
;
$data
[
'parentlevel'
]
=
$parentlevel
;
$data
[
'parentlevel'
]
=
$parentlevel
;
$data
[
'urutan'
]
=
$urutan
+
1
;
$data
[
'urutan'
]
=
$urutan
+
1
;
$data
[
'parent'
]
=
$request
->
input
(
'parentpage'
);
$data
[
'parent'
]
=
$request
->
input
(
'parentpage'
);
$data
[
'url'
]
=
'/page/'
.
$page
->
slug
;
$data
[
'url'
]
=
'/page/'
.
$page
->
slug
;
$data
[
'status'
]
=
1
;
$data
[
'status'
]
=
1
;
...
@@ -252,7 +254,8 @@ class MenuController extends Controller
...
@@ -252,7 +254,8 @@ class MenuController extends Controller
Alert
::
success
(
'Data berhasil disimpan'
)
->
persistent
(
'Ok'
);
Alert
::
success
(
'Data berhasil disimpan'
)
->
persistent
(
'Ok'
);
$successmessage
=
"Proses Tambah Menu Berhasil !!"
;
$successmessage
=
'Proses Tambah Menu Berhasil !!'
;
return
redirect
()
->
route
(
'menu.index'
)
->
with
(
'successMessage'
,
$successmessage
);
return
redirect
()
->
route
(
'menu.index'
)
->
with
(
'successMessage'
,
$successmessage
);
}
}
}
}
...
@@ -261,22 +264,22 @@ class MenuController extends Controller
...
@@ -261,22 +264,22 @@ class MenuController extends Controller
* Display the specified resource.
* Display the specified resource.
*
*
* @param \App\Models\Menu $menu
* @param \App\Models\Menu $menu
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response
*/
*/
public
function
show
(
Menu
$menu
)
public
function
show
(
Menu
$menu
)
{
{
//
}
}
/**
/**
* Show the form for editing the specified resource.
* Show the form for editing the specified resource.
*
*
* @param \App\Models\Menu $menu
* @param \App\Models\Menu $menu
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response
*/
*/
public
function
edit
(
Menu
$menu
)
public
function
edit
(
Menu
$menu
)
{
{
//
}
}
/**
/**
...
@@ -284,17 +287,18 @@ class MenuController extends Controller
...
@@ -284,17 +287,18 @@ class MenuController extends Controller
*
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
* @param \App\Models\Menu $menu
* @param \App\Models\Menu $menu
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response
*/
*/
public
function
update
(
Request
$request
,
Menu
$menu
)
public
function
update
(
Request
$request
,
Menu
$menu
)
{
{
//
}
}
/**
/**
* Remove the specified resource from storage.
* Remove the specified resource from storage.
*
*
* @param \App\Models\Menu $menu
* @param \App\Models\Menu $menu
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response
*/
*/
public
function
destroy
(
$id
)
public
function
destroy
(
$id
)
...
...
app/Models/Webprofile/Menu.php
View file @
e40dde27
...
@@ -13,7 +13,9 @@ class Menu extends Model
...
@@ -13,7 +13,9 @@ class Menu extends Model
public
$incrementing
=
false
;
public
$incrementing
=
false
;
protected
$table
=
'swp_menus'
;
protected
$table
=
'swp_menus'
;
protected
$guarded
=
[];
protected
$fillable
=
[
'id'
,
'name'
,
'url'
,
'mode'
,
'status'
,
'parent'
,
'urutan'
,
'parentlevel'
,
'level'
,
'userid_created'
,
'userid_updated'
,
];
public
static
$rules
=
[
public
static
$rules
=
[
// 'name' => 'required',
// 'name' => 'required',
...
...
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