Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
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
Platform
Commits
a49dce12
Commit
a49dce12
authored
Oct 19, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the get all settings for modules
parent
574faaae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
4 deletions
+40
-4
SettingController.php
Http/Controllers/Admin/SettingController.php
+10
-2
EloquentSettingRepository.php
Repositories/Eloquent/EloquentSettingRepository.php
+19
-1
SettingRepository.php
Repositories/SettingRepository.php
+8
-0
settings.blade.php
Resources/views/admin/settings.blade.php
+3
-1
No files found.
Http/Controllers/Admin/SettingController.php
View file @
a49dce12
...
...
@@ -6,6 +6,7 @@ use Laracasts\Flash\Flash;
use
Modules\Core\Http\Controllers\Admin\AdminBaseController
;
use
Modules\Setting\Http\Requests\SettingRequest
;
use
Modules\Setting\Repositories\SettingRepository
;
use
Pingpong\Modules\Module
;
class
SettingController
extends
AdminBaseController
{
...
...
@@ -13,19 +14,26 @@ class SettingController extends AdminBaseController
* @var SettingRepository
*/
private
$setting
;
/**
* @var Module
*/
private
$module
;
public
function
__construct
(
SettingRepository
$setting
)
public
function
__construct
(
SettingRepository
$setting
,
Module
$module
)
{
parent
::
__construct
();
$this
->
setting
=
$setting
;
$this
->
module
=
$module
;
}
public
function
index
()
{
$settings
=
$this
->
setting
->
all
();
return
View
::
make
(
'setting::admin.settings'
,
compact
(
'settings'
));
$modulesWithSettings
=
$this
->
setting
->
moduleSettings
(
$this
->
module
->
enabled
());
return
View
::
make
(
'setting::admin.settings'
,
compact
(
'settings'
,
'modulesWithSettings'
));
}
public
function
store
(
SettingRequest
$request
)
...
...
Repositories/Eloquent/EloquentSettingRepository.php
View file @
a49dce12
<?php
namespace
Modules\Setting\Repositories\Eloquent
;
use
Illuminate\Support\Facades\Config
;
use
Modules\Core\Repositories\Eloquent\EloquentBaseRepository
;
use
Modules\Setting\Repositories\SettingRepository
;
use
Pingpong\Modules\Module
;
class
EloquentSettingRepository
extends
EloquentBaseRepository
implements
SettingRepository
{
...
...
@@ -117,4 +118,21 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
}
}
/**
* Return all modules that have settings
* with its settings
* @param array $modules
* @return array
*/
public
function
moduleSettings
(
array
$modules
)
{
$modulesWithSettings
=
[];
foreach
(
$modules
as
$module
)
{
if
(
$moduleSettings
=
Config
::
get
(
strtolower
(
$module
)
.
"::settings"
))
{
$modulesWithSettings
[
$module
]
=
$moduleSettings
;
}
}
return
$modulesWithSettings
;
}
}
Repositories/SettingRepository.php
View file @
a49dce12
...
...
@@ -17,4 +17,12 @@ interface SettingRepository extends BaseRepository
* @return mixed
*/
public
function
findByName
(
$settingName
);
/**
* Return all modules that have settings
* with its settings
* @param array $modules
* @return array
*/
public
function
moduleSettings
(
array
$modules
);
}
Resources/views/admin/settings.blade.php
View file @
a49dce12
...
...
@@ -45,7 +45,9 @@
<div
class=
"box-header"
><h3
class=
"box-title"
>
Module Settings
</h3></div>
<div
class=
"box-body"
>
<ul>
<li><a href="">Module 1</a></li>
<?php
foreach
(
$modulesWithSettings
as
$module
=>
$settings
)
:
?>
<li><a
href=
""
>
{{ $module }}
</a></li>
<?php
endforeach
;
?>
</ul>
</div>
</div>
...
...
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