<commit_before><?php

namespace Bishopm\Connexion\Http\Controllers;

use Bishopm\Connexion\Repositories\SettingsRepository;
use Bishopm\Connexion\Repositories\SocietiesRepository;
use Bishopm\Connexion\Repositories\GroupsRepository;
use Bishopm\Connexion\Models\Setting;
use App\Http\Controllers\Controller;
use Bishopm\Connexion\Http\Requests\CreateSettingRequest;
use Bishopm\Connexion\Http\Requests\UpdateSettingRequest;
use Spatie\Analytics\Period;

class SettingsController extends Controller {

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */

    private $setting,$societies,$groups;

    public function __construct(SettingsRepository $setting, SocietiesRepository $societies, GroupsRepository $groups)
    {
        $this->setting = $setting;
        $this->societies = $societies;
        $this->groups = $groups;
    }

    public function index()
    {
        $allset = $this->setting->allsettings();
        foreach ($allset as $setting){
            $settings[$setting['category']][]=$setting;
        }
        ksort($settings);
        return view('connexion::settings.index',compact('settings'));
    }

    public function modulesindex()
    {
        $modules = $this->setting->allmodules();
        return view('connexion::settings.modules',compact('modules'));
    }

    public function modulestoggle($module)
    {
        $modules = $this->setting->allmodules();
        $module = $this->setting->find($module);
        if ($module->setting_value=="yes"){
            $module->setting_value="no";
        } else {
            $module->setting_value="yes";
        }
        $module->save();
        return redirect()->route('admin.modules.index');
    }    

    public function edit(Setting $setting)
    {
        if ($setting->setting_key=="society_name"){
            $vals=$this->societies->dropdown();
            $dropdown=array();
            foreach ($vals as $val){
                $dum[0]=$val->id;
                $dum[1]=$val->society;
                $dropdown[]=$dum;
            }
        } elseif ($setting->setting_key=="pastoral_group"){
            $vals=$this->groups->dropdown();
            $dropdown=array();
            foreach ($vals as $val){
                $dum[0]=$val->id;
                $dum[1]=$val->groupname;
                $dropdown[]=$dum;
            }
        } elseif ($setting->setting_key=="sms_provider"){
            $dropdown[0][0]="bulksms";
            $dropdown[0][1]="bulksms";
            $dropdown[1][0]="smsfactory";
            $dropdown[1][1]="smsfactory";
        } else {
            $dropdown='';
        }
        return view('connexion::settings.edit', compact('setting','dropdown'));
    }

    public function create()
    {
        return view('connexion::settings.create');
    }

    public function store(CreateSettingRequest $request)
    {
        $this->setting->create($request->all());

        return redirect()->route('admin.settings.index')
            ->withSuccess('New setting added');
    }
    
    public function update(Setting $setting, UpdateSettingRequest $request)
    {
        $this->setting->update($setting, $request->all());
        return redirect()->route('admin.settings.index')->withSuccess('Setting has been updated');
    }

    public function analytics()
    {
        $analytics=Analytics::fetchMostVisitedPages(Period::days(7));
        return view('connexion::settings.analytics', compact('analytics'));   
    }

}<commit_msg>Logging users<commit_after><?php

namespace Bishopm\Connexion\Http\Controllers;

use Bishopm\Connexion\Repositories\SettingsRepository;
use Bishopm\Connexion\Repositories\SocietiesRepository;
use Bishopm\Connexion\Repositories\GroupsRepository;
use Bishopm\Connexion\Models\Setting;
use App\Http\Controllers\Controller;
use Bishopm\Connexion\Http\Requests\CreateSettingRequest;
use Bishopm\Connexion\Http\Requests\UpdateSettingRequest;
use Spatie\Analytics\Period;
use Spatie\Analytics\Analytics;

class SettingsController extends Controller {

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */

    private $setting,$societies,$groups;

    public function __construct(SettingsRepository $setting, SocietiesRepository $societies, GroupsRepository $groups)
    {
        $this->setting = $setting;
        $this->societies = $societies;
        $this->groups = $groups;
    }

    public function index()
    {
        $allset = $this->setting->allsettings();
        foreach ($allset as $setting){
            $settings[$setting['category']][]=$setting;
        }
        ksort($settings);
        return view('connexion::settings.index',compact('settings'));
    }

    public function modulesindex()
    {
        $modules = $this->setting->allmodules();
        return view('connexion::settings.modules',compact('modules'));
    }

    public function modulestoggle($module)
    {
        $modules = $this->setting->allmodules();
        $module = $this->setting->find($module);
        if ($module->setting_value=="yes"){
            $module->setting_value="no";
        } else {
            $module->setting_value="yes";
        }
        $module->save();
        return redirect()->route('admin.modules.index');
    }    

    public function edit(Setting $setting)
    {
        if ($setting->setting_key=="society_name"){
            $vals=$this->societies->dropdown();
            $dropdown=array();
            foreach ($vals as $val){
                $dum[0]=$val->id;
                $dum[1]=$val->society;
                $dropdown[]=$dum;
            }
        } elseif ($setting->setting_key=="pastoral_group"){
            $vals=$this->groups->dropdown();
            $dropdown=array();
            foreach ($vals as $val){
                $dum[0]=$val->id;
                $dum[1]=$val->groupname;
                $dropdown[]=$dum;
            }
        } elseif ($setting->setting_key=="sms_provider"){
            $dropdown[0][0]="bulksms";
            $dropdown[0][1]="bulksms";
            $dropdown[1][0]="smsfactory";
            $dropdown[1][1]="smsfactory";
        } else {
            $dropdown='';
        }
        return view('connexion::settings.edit', compact('setting','dropdown'));
    }

    public function create()
    {
        return view('connexion::settings.create');
    }

    public function store(CreateSettingRequest $request)
    {
        $this->setting->create($request->all());

        return redirect()->route('admin.settings.index')
            ->withSuccess('New setting added');
    }
    
    public function update(Setting $setting, UpdateSettingRequest $request)
    {
        $this->setting->update($setting, $request->all());
        return redirect()->route('admin.settings.index')->withSuccess('Setting has been updated');
    }

    public function analytics()
    {
        $analytics=Analytics::fetchMostVisitedPages(Period::days(7));
        return view('connexion::settings.analytics', compact('analytics'));   
    }

}
{'fraction_non_alphanumeric': 0.15166619196810024, 'fraction_numerical': 0.00370264881800057, 'mean_word_length': 2.579510703363914, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5440579', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1956, 'n_words': 311}