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
8e0e5b01
Commit
8e0e5b01
authored
Oct 19, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Showing the basic module settings form
parent
55fba3d6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
10 deletions
+55
-10
SettingController.php
Http/Controllers/Admin/SettingController.php
+4
-2
EloquentSettingRepository.php
Repositories/Eloquent/EloquentSettingRepository.php
+32
-6
SettingRepository.php
Repositories/SettingRepository.php
+7
-0
module-settings.blade.php
Resources/views/admin/module-settings.blade.php
+2
-2
module-fields.blade.php
Resources/views/admin/partials/module-fields.blade.php
+10
-0
No files found.
Http/Controllers/Admin/SettingController.php
View file @
8e0e5b01
...
...
@@ -46,9 +46,11 @@ class SettingController extends AdminBaseController
public
function
getModuleSettings
(
$module
)
{
$module
With
Settings
=
$this
->
setting
->
moduleSettings
(
$module
);
$moduleSettings
=
$this
->
setting
->
moduleSettings
(
$module
);
return
View
::
make
(
'setting::admin.module-settings'
,
compact
(
'module'
));
$settings
=
$this
->
setting
->
savedModuleSettings
(
$module
);
return
View
::
make
(
'setting::admin.module-settings'
,
compact
(
'module'
,
'moduleSettings'
,
'settings'
));
}
public
function
postModuleSettings
(
$module
)
...
...
Repositories/Eloquent/EloquentSettingRepository.php
View file @
8e0e5b01
...
...
@@ -3,7 +3,6 @@
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
{
...
...
@@ -53,7 +52,8 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
foreach
(
$settings
as
$settingName
=>
$settingValues
)
{
// Check if setting exists
if
(
$setting
=
$this
->
findByName
(
$settingName
))
{
$this
->
updateSetting
(
$setting
,
$settingValues
);
continue
;
$this
->
updateSetting
(
$setting
,
$settingValues
);
continue
;
}
$this
->
createForName
(
$settingName
,
$settingValues
);
}
...
...
@@ -75,10 +75,12 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
*/
public
function
findByName
(
$settingName
)
{
return
$this
->
model
->
whereHas
(
'translations'
,
function
(
$q
)
use
(
$settingName
)
{
$q
->
where
(
'name'
,
$settingName
);
})
->
first
();
return
$this
->
model
->
whereHas
(
'translations'
,
function
(
$q
)
use
(
$settingName
)
{
$q
->
where
(
'name'
,
$settingName
);
}
)
->
first
();
}
/**
...
...
@@ -126,6 +128,10 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
*/
public
function
moduleSettings
(
$modules
)
{
if
(
is_string
(
$modules
))
{
return
Config
::
get
(
strtolower
(
$modules
)
.
"::settings"
);
}
$modulesWithSettings
=
[];
foreach
(
$modules
as
$module
)
{
if
(
$moduleSettings
=
Config
::
get
(
strtolower
(
$module
)
.
"::settings"
))
{
...
...
@@ -135,4 +141,24 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
return
$modulesWithSettings
;
}
/**
* Return the saved module settings
* @param $module
* @return mixed
*/
public
function
savedModuleSettings
(
$module
)
{
return
$this
->
findByModule
(
$module
);
}
/**
* Find settings by module name
* @param string $module Module name
* @return mixed
*/
private
function
findByModule
(
$module
)
{
return
$this
->
model
->
where
(
'name'
,
"
$module
%"
)
->
get
();
}
}
Repositories/SettingRepository.php
View file @
8e0e5b01
...
...
@@ -25,4 +25,11 @@ interface SettingRepository extends BaseRepository
* @return array
*/
public
function
moduleSettings
(
$modules
);
/**
* Return the saved module settings
* @param $module
* @return mixed
*/
public
function
savedModuleSettings
(
$module
);
}
Resources/views/admin/module-settings.blade.php
View file @
8e0e5b01
...
...
@@ -25,10 +25,10 @@
</
ul
>
<
div
class
="
tab
-
content
">
<div class="
tab
-
pane
{{
App
::
getLocale
()
==
'en'
?
'active'
:
''
}}
" id="
tab_1
-
1
">
@include('setting::admin.partials.
fields', ['lang' => 'en'
])
@include('setting::admin.partials.
module-fields', ['lang' => 'en', 'moduleSettings' =>
$moduleSettings
, 'settings' =>
$settings
])
</div>
<div class="
tab
-
pane
{{
App
::
getLocale
()
==
'fr'
?
'active'
:
''
}}
" id="
tab_2
-
2
">
@include('setting::admin.partials.
fields', ['lang' => 'fr'
])
@include('setting::admin.partials.
module-fields', ['lang' => 'fr', 'moduleSettings' =>
$moduleSettings
, 'settings' =>
$settings
])
</div>
</div>
</div>
...
...
Resources/views/admin/partials/module-fields.blade.php
0 → 100644
View file @
8e0e5b01
<?php
foreach
(
$moduleSettings
as
$setting
=>
$description
)
:
?>
<div
class=
'form-group'
>
{!! Form::label($setting . "[$lang]", $description) !!}
<?php
if
(
count
(
$settings
)
>=
1
)
:
?>
{!! Form::text($setting . "[$lang]", Input::old($setting . "[$lang]", $settings[$setting]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $description]) !!}
<?php
else
:
?>
{!! Form::text($setting . "[$lang]", Input::old($setting . "[$lang]"), ['class' => 'form-control', 'placeholder' => $description]) !!}
<?php
endif
;
?>
</div>
<?php
endforeach
;
?>
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