Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
6e3c77cf
Unverified
Commit
6e3c77cf
authored
Dec 10, 2017
by
Viral Solani
Committed by
GitHub
Dec 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #80 from viralsolani/analysis-Xk6Yly
Apply fixes from StyleCI
parents
bf7ae98d
e8bd9d7d
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
66 additions
and
64 deletions
+66
-64
MenuController.php
app/Http/Controllers/Backend/Menu/MenuController.php
+25
-18
MenuFormController.php
app/Http/Controllers/Backend/Menu/MenuFormController.php
+4
-3
MenuTableController.php
app/Http/Controllers/Backend/Menu/MenuTableController.php
+2
-3
CreateMenuRequest.php
app/Http/Requests/Backend/Menu/CreateMenuRequest.php
+1
-1
DeleteMenuRequest.php
app/Http/Requests/Backend/Menu/DeleteMenuRequest.php
+1
-1
EditMenuRequest.php
app/Http/Requests/Backend/Menu/EditMenuRequest.php
+1
-1
Menu.php
app/Models/Menu/Menu.php
+4
-4
MenuAttribute.php
app/Models/Menu/Traits/Attribute/MenuAttribute.php
+2
-2
MenuRepository.php
app/Repositories/Backend/Menu/MenuRepository.php
+5
-8
2017_12_10_122555_create_menus_table.php
database/migrations/2017_12_10_122555_create_menus_table.php
+2
-2
MenuTableSeeder.php
database/seeds/MenuTableSeeder.php
+2
-3
ModulesTableSeeder.php
database/seeds/ModulesTableSeeder.php
+14
-15
Menu.php
routes/Backend/Menu.php
+3
-3
No files found.
app/Http/Controllers/Backend/Menu/MenuController.php
View file @
6e3c77cf
...
...
@@ -2,16 +2,15 @@
namespace
App\Http\Controllers\Backend\Menu
;
use
App\Models\Menu\Menu
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
App\Repositories\Backend\Menu\MenuRepository
;
use
App\Http\Requests\Backend\Menu\StoreMenuRequest
;
use
App\Http\Requests\Backend\Menu\ManageMenuRequest
;
use
App\Http\Requests\Backend\Menu\CreateMenuRequest
;
use
App\Http\Requests\Backend\Menu\EditMenuRequest
;
use
App\Http\Requests\Backend\Menu\DeleteMenuRequest
;
use
App\Http\Requests\Backend\Menu\EditMenuRequest
;
use
App\Http\Requests\Backend\Menu\ManageMenuRequest
;
use
App\Http\Requests\Backend\Menu\StoreMenuRequest
;
use
App\Http\Requests\Backend\Menu\UpdateMenuRequest
;
use
App\Models\Menu\Menu
;
use
App\Repositories\Backend\Menu\MenuRepository
;
use
Illuminate\Support\Facades\DB
;
class
MenuController
extends
Controller
...
...
@@ -28,6 +27,7 @@ class MenuController extends Controller
/**
* Display a listing of the resource.
*
* @param \App\Http\Requests\Backend\Menu\ManageMenuRequest $request
*
* @return \Illuminate\Http\Response
...
...
@@ -39,6 +39,7 @@ class MenuController extends Controller
/**
* Show the form for creating a new resource.
*
* @param \App\Http\Requests\Backend\Menu\CreateMenuRequest $request
*
* @return \Illuminate\Http\Response
...
...
@@ -46,17 +47,19 @@ class MenuController extends Controller
public
function
create
(
CreateMenuRequest
$request
)
{
$types
=
[
"backend"
=>
"Backend"
,
"frontend"
=>
"Frontend"
'backend'
=>
'Backend'
,
'frontend'
=>
'Frontend'
,
];
$modules
=
DB
::
table
(
'modules'
)
->
get
();
return
view
(
'backend.menus.create'
)
->
withTypes
(
$types
)
->
withModules
(
$modules
);
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\Backend\Menu\StoreMenuRequest $request
*
*
* @return \Illuminate\Http\Response
*/
public
function
store
(
StoreMenuRequest
$request
)
...
...
@@ -68,19 +71,21 @@ class MenuController extends Controller
/**
* Show the form for editing the specified resource.
* @param \App\Models\Menu\Menu $menu
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\EditMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public
function
edit
(
Menu
$menu
,
EditMenuRequest
$request
)
{
$types
=
[
"backend"
=>
"Backend"
,
"frontend"
=>
"Frontend"
'backend'
=>
'Backend'
,
'frontend'
=>
'Frontend'
,
];
$modules
=
DB
::
table
(
'modules'
)
->
get
();
return
view
(
'backend.menus.edit'
)
->
with
(
'types'
,
$types
)
->
with
(
'menu'
,
$menu
)
...
...
@@ -90,9 +95,9 @@ class MenuController extends Controller
/**
* Update the specified resource in storage.
*
* @param
\App\Models\Menu\Menu
$menu
* @param
\App\Http\Requests\Backend\Menu\UpdateMenuRequest
$request
*
* @param
\App\Models\Menu\Menu
$menu
* @param
\App\Http\Requests\Backend\Menu\UpdateMenuRequest
$request
*
* @return \Illuminate\Http\Response
*/
public
function
update
(
Menu
$menu
,
UpdateMenuRequest
$request
)
...
...
@@ -106,8 +111,10 @@ class MenuController extends Controller
/**
* Remove the specified resource from storage.
* @param \App\Models\Menu\Menu $menu
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\DeleteMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public
function
destroy
(
Menu
$menu
,
DeleteMenuRequest
$request
)
...
...
app/Http/Controllers/Backend/Menu/MenuFormController.php
View file @
6e3c77cf
...
...
@@ -9,6 +9,7 @@ class MenuFormController extends Controller
{
/**
* Get the form for modal popup.
*
* @param string $formName
* @param \App\Http\Requests\Backend\Menu\CreateMenuRequest
*
...
...
@@ -16,10 +17,10 @@ class MenuFormController extends Controller
*/
public
function
create
(
$formName
,
CreateMenuRequest
$request
)
{
if
(
in_array
(
$formName
,
[
'_add_custom_url_form'
]))
{
if
(
in_array
(
$formName
,
[
'_add_custom_url_form'
]))
{
return
view
(
'backend.menus.'
.
$formName
);
}
return
abort
(
404
);
}
}
\ No newline at end of file
}
app/Http/Controllers/Backend/Menu/MenuTableController.php
View file @
6e3c77cf
...
...
@@ -2,12 +2,11 @@
namespace
App\Http\Controllers\Backend\Menu
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
Yajra\DataTables\Facades\DataTables
;
use
App\Repositories\Backend\Menu\MenuRepository
;
use
App\Http\Requests\Backend\Menu\ManageMenuRequest
;
use
App\Repositories\Backend\Menu\MenuRepository
;
use
Carbon\Carbon
;
use
Yajra\DataTables\Facades\DataTables
;
/**
* Class MenuTableController.
...
...
app/Http/Requests/Backend/Menu/CreateMenuRequest.php
View file @
6e3c77cf
...
...
@@ -5,7 +5,7 @@ namespace App\Http\Requests\Backend\Menu;
use
App\Http\Requests\Request
;
/**
* Class CreateMenuRequest
* Class CreateMenuRequest
.
*/
class
CreateMenuRequest
extends
Request
{
...
...
app/Http/Requests/Backend/Menu/DeleteMenuRequest.php
View file @
6e3c77cf
...
...
@@ -5,7 +5,7 @@ namespace App\Http\Requests\Backend\Menu;
use
App\Http\Requests\Request
;
/**
* Class DeleteMenuRequest
* Class DeleteMenuRequest
.
*/
class
DeleteMenuRequest
extends
Request
{
...
...
app/Http/Requests/Backend/Menu/EditMenuRequest.php
View file @
6e3c77cf
...
...
@@ -5,7 +5,7 @@ namespace App\Http\Requests\Backend\Menu;
use
App\Http\Requests\Request
;
/**
* Class EditMenuRequest
* Class EditMenuRequest
.
*/
class
EditMenuRequest
extends
Request
{
...
...
app/Models/Menu/Menu.php
View file @
6e3c77cf
...
...
@@ -2,9 +2,9 @@
namespace
App\Models\Menu
;
use
Illuminate\Database\Eloquent\Model
;
use
App\Models\ModelTrait
;
use
App\Models\Menu\Traits\Attribute\MenuAttribute
;
use
App\Models\ModelTrait
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
class
Menu
extends
Model
...
...
@@ -25,12 +25,12 @@ class Menu extends Model
protected
$fillable
=
[
'name'
,
'type'
,
'items'
'items'
,
];
public
function
__construct
(
array
$attributes
=
[])
{
parent
::
__construct
(
$attributes
);
$this
->
table
=
config
(
"access.menus_table"
);
$this
->
table
=
config
(
'access.menus_table'
);
}
}
app/Models/Menu/Traits/Attribute/MenuAttribute.php
View file @
6e3c77cf
...
...
@@ -13,8 +13,8 @@ trait MenuAttribute
public
function
getActionButtonsAttribute
()
{
return
'<div class="btn-group action-btn">
'
.
$this
->
getEditButtonAttribute
(
'edit-menu'
,
'admin.menus.edit'
)
.
'
'
.
$this
->
getDeleteButtonAttribute
(
'delete-menu'
,
'admin.menus.destroy'
)
.
'
'
.
$this
->
getEditButtonAttribute
(
'edit-menu'
,
'admin.menus.edit'
)
.
'
'
.
$this
->
getDeleteButtonAttribute
(
'delete-menu'
,
'admin.menus.destroy'
)
.
'
</div>'
;
}
}
app/Repositories/Backend/Menu/MenuRepository.php
View file @
6e3c77cf
...
...
@@ -2,18 +2,17 @@
namespace
App\Repositories\Backend\Menu
;
use
App\Repositories\BaseRepository
;
use
App\Exceptions\GeneralException
;
use
App\Models\Menu\Menu
;
use
App\Repositories\BaseRepository
;
use
Illuminate\Database\Eloquent\Model
;
use
DB
;
/**
* Class MenuRepository.
*/
class
MenuRepository
extends
BaseRepository
{
/**
/**
* Associated Repository Model.
*/
const
MODEL
=
Menu
::
class
;
...
...
@@ -63,13 +62,12 @@ class MenuRepository extends BaseRepository
*
* return bool
*/
public
function
update
(
Menu
$menu
,
array
$input
)
{
if
(
$this
->
query
()
->
where
(
'name'
,
$input
[
'name'
])
->
where
(
"id"
,
'!='
,
$menu
->
id
)
->
first
())
{
if
(
$this
->
query
()
->
where
(
'name'
,
$input
[
'name'
])
->
where
(
'id'
,
'!='
,
$menu
->
id
)
->
first
())
{
throw
new
GeneralException
(
trans
(
'exceptions.backend.menus.already_exists'
));
}
$input
[
'updated_by'
]
=
access
()
->
user
()
->
id
;
if
(
$menu
->
update
(
$input
))
{
...
...
@@ -77,7 +75,6 @@ class MenuRepository extends BaseRepository
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.menus.update_error'
));
}
/**
...
...
@@ -95,4 +92,4 @@ class MenuRepository extends BaseRepository
throw
new
GeneralException
(
trans
(
'exceptions.backend.menus.delete_error'
));
}
}
\ No newline at end of file
}
database/migrations/2017_12_10_122555_create_menus_table.php
View file @
6e3c77cf
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateMenusTable
extends
Migration
{
...
...
database/seeds/MenuTableSeeder.php
View file @
6e3c77cf
<?php
use
Carbon\Carbon
;
use
Database\TruncateTable
;
use
Illuminate\Database\Seeder
;
use
Illuminate\Support\Facades\DB
;
...
...
@@ -18,10 +17,10 @@ class MenuTableSeeder extends Seeder
$menu
=
[
'id'
=>
1
,
'type'
=>
'backend'
,
'name'
=>
"Backend Sidebar Menu"
,
'name'
=>
'Backend Sidebar Menu'
,
'items'
=>
'[{"view_permission_id":"view-access-management","icon":"fa-users","open_in_new_tab":0,"url_type":"route","url":"","name":"Access Management","id":11,"content":"Access Management","children":[{"view_permission_id":"view-user-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.user.index","name":"User Management","id":12,"content":"User Management"},{"view_permission_id":"view-role-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.role.index","name":"Role Management","id":13,"content":"Role Management"},{"view_permission_id":"view-permission-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.permission.index","name":"Permission Management","id":14,"content":"Permission Management"}]},{"view_permission_id":"view-module","icon":"fa-wrench","open_in_new_tab":0,"url_type":"route","url":"admin.modules.index","name":"Module","id":1,"content":"Module"},{"view_permission_id":"view-menu","icon":"fa-bars","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"view_permission_id":"view-page","icon":"fa-file-text","open_in_new_tab":0,"url_type":"route","url":"admin.pages.index","name":"Pages","id":2,"content":"Pages"},{"view_permission_id":"view-email-template","icon":"fa-envelope","open_in_new_tab":0,"url_type":"route","url":"admin.emailtemplates.index","name":"Email Templates","id":8,"content":"Email Templates"},{"view_permission_id":"edit-settings","icon":"fa-gear","open_in_new_tab":0,"url_type":"route","url":"admin.settings.edit?id=1","name":"Settings","id":9,"content":"Settings"},{"view_permission_id":"view-blog","icon":"fa-commenting","open_in_new_tab":0,"url_type":"route","url":"","name":"Blog Management","id":15,"content":"Blog Management","children":[{"view_permission_id":"view-blog-category","open_in_new_tab":0,"url_type":"route","url":"admin.blogcategories.index","name":"Blog Category Management","id":16,"content":"Blog Category Management"},{"view_permission_id":"view-blog-tag","open_in_new_tab":0,"url_type":"route","url":"admin.blogtags.index","name":"Blog Tag Management","id":17,"content":"Blog Tag Management"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"admin.blogs.index","name":"Blog Management","id":18,"content":"Blog Management"}]},{"view_permission_id":"view-faq","icon":"fa-question-circle","open_in_new_tab":0,"url_type":"route","url":"admin.faqs.index","name":"Faq Management","id":19,"content":"Faq Management"}]'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
];
DB
::
table
(
config
(
'access.menus_table'
))
->
insert
(
$menu
);
...
...
database/seeds/ModulesTableSeeder.php
View file @
6e3c77cf
...
...
@@ -6,7 +6,6 @@ use Illuminate\Support\Facades\DB;
class
ModulesTableSeeder
extends
Seeder
{
/**
* Run the database seeds.
*
...
...
@@ -22,98 +21,98 @@ class ModulesTableSeeder extends Seeder
'url'
=>
null
,
'view_permission_id'
=>
'view-access-management'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'labels.backend.access.users.management'
),
'url'
=>
'admin.access.user.index'
,
'view_permission_id'
=>
'view-user-management'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'labels.backend.access.roles.management'
),
'url'
=>
'admin.access.role.index'
,
'view_permission_id'
=>
'view-role-management'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'labels.backend.access.permissions.management'
),
'url'
=>
'admin.access.permission.index'
,
'view_permission_id'
=>
'view-permission-management'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'labels.backend.menus.title'
),
'url'
=>
'admin.menus.index'
,
'view_permission_id'
=>
'view-menu'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'labels.backend.modules.title'
),
'url'
=>
'admin.modules.index'
,
'view_permission_id'
=>
'view-module'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'labels.backend.pages.title'
),
'url'
=>
'admin.pages.index'
,
'view_permission_id'
=>
'view-page'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'labels.backend.emailtemplates.title'
),
'url'
=>
'admin.emailtemplates.index'
,
'view_permission_id'
=>
'view-email-template'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'labels.backend.settings.title'
),
'url'
=>
'admin.settings.edit'
,
'view_permission_id'
=>
'edit-settings'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'menus.backend.blog.management'
),
'url'
=>
null
,
'view_permission_id'
=>
'view-blog'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'menus.backend.blogcategories.management'
),
'url'
=>
'admin.blogcategories.index'
,
'view_permission_id'
=>
'view-blog-category'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'menus.backend.blogtags.management'
),
'url'
=>
'admin.blogtags.index'
,
'view_permission_id'
=>
'view-blog-tag'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'menus.backend.blog.management'
),
'url'
=>
'admin.blogs.index'
,
'view_permission_id'
=>
'view-blog'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
[
'name'
=>
trans
(
'menus.backend.faqs.management'
),
'url'
=>
'admin.faqs.index'
,
'view_permission_id'
=>
'view-faq'
,
'created_by'
=>
1
,
'created_at'
=>
Carbon
::
now
()
'created_at'
=>
Carbon
::
now
()
,
],
];
...
...
routes/Backend/Menu.php
View file @
6e3c77cf
<?php
/**
* Menu Management
* Menu Management
.
*/
Route
::
group
([
'namespace'
=>
'Menu'
],
function
()
{
Route
::
resource
(
'menus'
,
'MenuController'
,
[
'except'
=>
[]]);
//For DataTables
Route
::
post
(
'menus/get'
,
'MenuTableController'
)
->
name
(
'menus.get'
);
// for Model Forms
// for Model Forms
Route
::
get
(
'menus/get-form/{name?}'
,
'MenuFormController@create'
)
->
name
(
'menus.getform'
);
});
\ No newline at end of file
});
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