<commit_before><?php

namespace SystemInc\LaravelAdmin\Http\Controllers;

use App\Http\Controllers\Controller;
use Hash;
use Illuminate\Http\Request;
use Storage;
use SystemInc\LaravelAdmin\Admin;
use SystemInc\LaravelAdmin\Setting;
use SystemInc\LaravelAdmin\Validations\AdminValidation;
use SystemInc\LaravelAdmin\Validations\AdminValidationWithoutPassword;

class SettingsController extends Controller
{
    public function __construct()
    {
        if (config('laravel-admin.modules.settings') == false) {
            return redirect(config('laravel-admin.route_prefix'))->with('error', 'This module is disabled in config/laravel-admin.php')->send();
        }
    }

    /**
     * Layouts controller index page.
     *
     * @return \Illuminate\Http\Response
     */
    public function getIndex()
    {
        $admins = Admin::all();

        $setting = Setting::first();

        return view('admin::settings.index', compact('admins', 'setting'));
    }

    /**
     * Update admin panel.
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\Response
     */
    public function postUpdate(Request $request)
    {
        $file = $request->file('logo');

        if ($file && $file->isValid()) {
            $dirname = 'admin-panel/'.$file->getClientOriginalName();

            Storage::deleteDirectory('admin-panel');
            Storage::put($dirname, file_get_contents($file));

            $source = $dirname;
        }
        $data = [
            'title'  => !empty($request->title) ? $request->title : null,
            'source' => !empty($source) ? $source : null,
        ];

        $setting = Setting::first();

        !empty($setting->id) ? $setting->update($data) : Setting::create($data);
<commit_msg>Admin settings logo upload fix and refactor<commit_after><?php

namespace SystemInc\LaravelAdmin\Http\Controllers;

use App\Http\Controllers\Controller;
use Hash;
use Illuminate\Http\Request;
use Storage;
use SystemInc\LaravelAdmin\Admin;
use SystemInc\LaravelAdmin\Setting;
use SystemInc\LaravelAdmin\Validations\AdminValidation;
use SystemInc\LaravelAdmin\Validations\AdminValidationWithoutPassword;

class SettingsController extends Controller
{
    public function __construct()
    {
        if (config('laravel-admin.modules.settings') == false) {
            return redirect(config('laravel-admin.route_prefix'))->with('error', 'This module is disabled in config/laravel-admin.php')->send();
        }
    }

    /**
     * Layouts controller index page.
     *
     * @return \Illuminate\Http\Response
     */
    public function getIndex()
    {
        $admins = Admin::all();

        $setting = Setting::first();

        return view('admin::settings.index', compact('admins', 'setting'));
    }

    /**
     * Update admin panel.
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\Response
     */
    public function postUpdate(Request $request)
    {
        $data = [];
        $data['title'] = !empty($request->title) ? $request->title : null;

        $file = $request->file('logo');

        if ($file && $file->isValid()) {
            $file_path = 'admin-panel/'.$file->getClientOriginalName();

            Storage::deleteDirectory('admin-panel');
            Storage::put($file_path, file_get_contents($file));

            $data['source'] = $file_path;
        }

        $setting = Setting::first();

        !empty($setting->id) ? $setting->update($data) : Setting::create($data);

{'fraction_non_alphanumeric': 0.1473201490398395, 'fraction_numerical': 0.0, 'mean_word_length': 2.8309549945115258, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '6071307', 'n_tokens_mistral': 1005, 'n_tokens_neox': 983, 'n_words': 186}