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
c6eb4c4b
Commit
c6eb4c4b
authored
Oct 16, 2017
by
bvipul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring Module Manager To a different Controller --pending
parent
e2e155d7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
47 deletions
+38
-47
.gitignore
.gitignore
+2
-0
Repository.stub
app/Console/Commands/Stubs/Repository.stub
+2
-2
ModuleController.php
app/Http/Controllers/Backend/Module/ModuleController.php
+15
-30
ModuleRepository.php
app/Repositories/Backend/Module/ModuleRepository.php
+14
-10
index.blade.php
resources/views/backend/menus/index.blade.php
+5
-5
No files found.
.gitignore
View file @
c6eb4c4b
...
@@ -22,3 +22,5 @@ Todo.rtf
...
@@ -22,3 +22,5 @@ Todo.rtf
npm-debug.log
npm-debug.log
yarn-error.log
yarn-error.log
phpunit.txt
phpunit.txt
public/css
public/js
app/Console/Commands/Stubs/Repository.stub
View file @
c6eb4c4b
...
@@ -45,7 +45,7 @@ class DummyRepoName extends BaseRepository
...
@@ -45,7 +45,7 @@ class DummyRepoName extends BaseRepository
public
function
create
(
array
$input
)
public
function
create
(
array
$input
)
{
{
$dummy_small_model_name
=
self
::
MODEL
;
$dummy_small_model_name
=
self
::
MODEL
;
if
(
$dummy_small_model_name
->
save
())
{
if
(
$dummy_small_model_name
->
save
(
$input
))
{
return
true
;
return
true
;
}
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.dummy_small_plural_model_name.create_error'
));
throw
new
GeneralException
(
trans
(
'exceptions.backend.dummy_small_plural_model_name.create_error'
));
...
@@ -61,7 +61,7 @@ class DummyRepoName extends BaseRepository
...
@@ -61,7 +61,7 @@ class DummyRepoName extends BaseRepository
*/
*/
public
function
update
(
dummy_model_name
$dummy_small_model_name
,
array
$input
)
public
function
update
(
dummy_model_name
$dummy_small_model_name
,
array
$input
)
{
{
if
(
$dummy_small_model_name
->
update
())
if
(
$dummy_small_model_name
->
update
(
$input
))
return
true
;
return
true
;
throw
new
GeneralException
(
trans
(
'exceptions.backend.dummy_small_plural_model_name.update_error'
));
throw
new
GeneralException
(
trans
(
'exceptions.backend.dummy_small_plural_model_name.update_error'
));
...
...
app/Http/Controllers/Backend/Module/ModuleController.php
View file @
c6eb4c4b
...
@@ -13,6 +13,7 @@ use Illuminate\Filesystem\Filesystem;
...
@@ -13,6 +13,7 @@ use Illuminate\Filesystem\Filesystem;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Artisan
;
use
Illuminate\Support\Facades\Artisan
;
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Support\Facades\Schema
;
use
App\Http\Utilities\Generator
;
class
ModuleController
extends
Controller
class
ModuleController
extends
Controller
{
{
...
@@ -21,6 +22,7 @@ class ModuleController extends Controller
...
@@ -21,6 +22,7 @@ class ModuleController extends Controller
public
$table
;
public
$table
;
public
$repository
;
public
$repository
;
public
$directory
;
public
$directory
;
public
$generator
;
public
$attribute
=
'Attribute'
;
public
$attribute
=
'Attribute'
;
public
$trait_directory
=
'Traits'
;
public
$trait_directory
=
'Traits'
;
public
$relationship
=
'Relationship'
;
public
$relationship
=
'Relationship'
;
...
@@ -42,6 +44,7 @@ class ModuleController extends Controller
...
@@ -42,6 +44,7 @@ class ModuleController extends Controller
{
{
$this
->
files
=
$files
;
$this
->
files
=
$files
;
$this
->
repository
=
$repository
;
$this
->
repository
=
$repository
;
$this
->
generator
=
new
Generator
();
}
}
/**
/**
...
@@ -80,37 +83,19 @@ class ModuleController extends Controller
...
@@ -80,37 +83,19 @@ class ModuleController extends Controller
*/
*/
public
function
store
(
StoreModuleRequest
$request
)
public
function
store
(
StoreModuleRequest
$request
)
{
{
//If Directory Name is available
$this
->
generator
->
initialize
(
$request
->
all
());
if
(
!
empty
(
$request
->
directory_name
))
{
$this
->
generator
->
createMigration
();
$this
->
directory
=
$request
->
directory_name
;
$this
->
generator
->
createModel
();
$this
->
model_namespace
.=
$this
->
directory
;
$this
->
generator
->
createRequests
();
$this
->
controller_namespace
.=
$this
->
directory
;
$this
->
generator
->
createRepository
();
$this
->
event_namespace
.=
$this
->
directory
;
$this
->
generator
->
createController
();
$this
->
view_path
.=
$this
->
directory
;
$this
->
generator
->
createTableController
();
$this
->
repo_namespace
.=
$this
->
directory
;
$this
->
generator
->
createRouteFiles
();
$this
->
request_namespace
.=
$this
->
directory
;
$this
->
generator
->
insertToLanguageFiles
();
}
$this
->
generator
->
createViewFiles
();
//If Model name is given
$this
->
generator
->
createEvents
();
if
(
!
empty
(
$request
->
model_name
))
{
$this
->
model
=
ucfirst
(
$request
->
model_name
);
}
$input
=
$request
->
all
();
//If table name is given
if
(
!
empty
(
$request
->
table_name
))
{
$this
->
table
=
$request
->
table_name
;
//Creating Migration
$this
->
createMigration
(
$input
);
}
else
{
$this
->
table
=
strtolower
(
str_plural
(
$this
->
model
));
}
//Creating Model
$model
=
$this
->
createModel
(
$input
);
//Creating Controller
$this
->
createController
(
$input
,
$model
);
// //Creating Event And Listeners
$this
->
createEvents
(
$input
);
//Creating the Module
//Creating the Module
$this
->
repository
->
create
(
$input
);
$this
->
repository
->
create
(
$request
->
all
(),
$this
->
generator
->
getPermissions
()
);
return
redirect
()
->
route
(
'admin.modules.index'
)
->
withFlashSuccess
(
'Module Generated Successfully!'
);
return
redirect
()
->
route
(
'admin.modules.index'
)
->
withFlashSuccess
(
'Module Generated Successfully!'
);
}
}
...
...
app/Repositories/Backend/Module/ModuleRepository.php
View file @
c6eb4c4b
...
@@ -42,29 +42,33 @@ class ModuleRepository extends BaseRepository
...
@@ -42,29 +42,33 @@ class ModuleRepository extends BaseRepository
*
*
* @return bool
* @return bool
*/
*/
public
function
create
(
array
$input
)
public
function
create
(
array
$input
,
array
$permissions
)
{
{
$module
=
Module
::
where
(
'name'
,
$input
[
'name'
])
->
first
();
$module
=
Module
::
where
(
'name'
,
$input
[
'name'
])
->
first
();
if
(
!
$module
)
{
if
(
!
$module
)
{
$name
=
$input
[
'model_name'
];
$name
=
$input
[
'model_name'
];
$model
=
strtolower
(
$name
);
$model
=
strtolower
(
$name
);
$permissions
=
//
$permissions =
[
//
[
[
'name'
=>
"view-
$model
-permission"
,
'display_name'
=>
'View '
.
ucwords
(
$model
)
.
' Permission'
],
//
['name' => "view-$model-permission", 'display_name' => 'View '.ucwords($model).' Permission'],
[
'name'
=>
"create-
$model
-permission"
,
'display_name'
=>
'Create '
.
ucwords
(
$model
)
.
' Permission'
],
//
['name' => "create-$model-permission", 'display_name' => 'Create '.ucwords($model).' Permission'],
[
'name'
=>
"edit-
$model
-permission"
,
'display_name'
=>
'Edit '
.
ucwords
(
$model
)
.
' Permission'
],
//
['name' => "edit-$model-permission", 'display_name' => 'Edit '.ucwords($model).' Permission'],
[
'name'
=>
"delete-
$model
-permission"
,
'display_name'
=>
'Delete '
.
ucwords
(
$model
)
.
' Permission'
],
//
['name' => "delete-$model-permission", 'display_name' => 'Delete '.ucwords($model).' Permission'],
];
//
];
foreach
(
$permissions
as
$permission
)
{
foreach
(
$permissions
as
$permission
)
{
$perm
=
[
'name'
=>
$permission
,
'display_name'
=>
title_case
(
str_replace
(
'-'
,
' '
,
$permission
)
)
.
" Permission"
];
//Creating Permission
//Creating Permission
$per
=
Permission
::
firstOrCreate
(
$perm
ission
);
$per
=
Permission
::
firstOrCreate
(
$perm
);
}
}
$mod
=
[
$mod
=
[
'view_permission_id'
=>
"view-
$model
-permission"
,
'view_permission_id'
=>
"view-
$model
-permission"
,
'name'
=>
$input
[
'name'
],
'name'
=>
$input
[
'name'
],
'url'
=>
'admin.'
.
str_plural
(
$model
)
.
'.index'
,
'url'
=>
'admin.'
.
str_plural
(
$model
)
.
'.index'
,
'created_by'
=>
access
()
->
user
()
->
id
,
'created_by'
=>
access
()
->
user
()
->
id
,
];
];
...
...
resources/views/backend/menus/index.blade.php
View file @
c6eb4c4b
...
@@ -81,11 +81,11 @@
...
@@ -81,11 +81,11 @@
dom: 'lBfrtip',
dom: 'lBfrtip',
buttons: {
buttons: {
buttons: [
buttons: [
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1, 2
, 3, 4
] }},
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1, 2 ] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1, 2
, 3, 4
] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1, 2 ] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1, 2
, 3, 4
] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1, 2 ] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1, 2
, 3, 4
] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1, 2 ] }},
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1, 2
, 3, 4
] }}
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1, 2 ] }}
]
]
}
}
});
});
...
...
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