Commit a49dce12 authored by Nicolas Widart's avatar Nicolas Widart

Add the get all settings for modules

parent 574faaae
......@@ -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)
......
<?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;
}
}
......@@ -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);
}
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment