<commit_before><?php

namespace App\Http\Controllers;

use App\Upload;
use App\User;

use App\Http\Requests;
use Auth;
use File;
use Mail;
use Session;

class AdminController extends Controller
{
    public function index()
    {
        return view('admin.index');
    }

    public function requests()
    {
        $users = User::where('enabled', 0)->orderBy('created_at', 'asc')->paginate(15);
        return view('admin.requests', compact('users'));
    }

    public function users()
    {
        $users = User::paginate(15);
        return view('admin.users', ['users' => $users]);
    }

    public function ban($user)
    {
        if ($user->id == 1) {
            Session::flash('alert',
                'You cannot ban the superuser account.');
            return redirect()->back();
        }
        $user->fill(['banned' => true])->save();
        return redirect()->back();
    }

    public function delete($user)
    {
        if ($user->id == 1) {
            Session::flash('alert',
                'You cannot delete the superuser account.');
            return redirect()->back();
        }
        $path = storage_path() . '/uploads/';
        foreach ($user->uploads as $upload) {
            $filePath = $path . $upload->name;
            if (File::isFile($filePath)) {
                File::delete($filePath);
            }
        }
        $user->forceDelete();
        return redirect()->back();
    }

    public function unban($user)
    {
        $user->fill(['banned' => false])->save();
        return redirect()->back();
    }

    public function uploads($user)
    {
        $uploads = Upload::where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(15);
        return view('admin.uploads', compact('uploads', 'user'));
    }

    public function enable($user)
    {
        $user->fill(['enabled' => true])->save();
        Mail::queue(['text' => 'emails.user.account_approved'], ['user' => $user], function($message) use ($user)
        {
            $message->from(env('SITE_EMAIL_FROM'), env('SITE_NAME'));
            $message->subject(sprintf("[%s] Account Approved", env('DOMAIN')));
            $message->to($user->email);
        });
        return redirect()->back();
    }
}<commit_msg>Right idea, wrong user<commit_after><?php

namespace App\Http\Controllers;

use App\Upload;
use App\User;

use App\Http\Requests;
use Auth;
use File;
use Mail;
use Session;

class AdminController extends Controller
{
    public function index()
    {
        return view('admin.index');
    }

    public function requests()
    {
        $users = User::where('enabled', 0)->orderBy('created_at', 'asc')->paginate(15);
        return view('admin.requests', compact('users'));
    }

    public function users()
    {
        $users = User::paginate(15);
        return view('admin.users', ['users' => $users]);
    }

    public function ban($user)
    {
        if ($user->id == 1) {
            Session::flash('alert',
                'You cannot ban the superuser account.');
            return redirect()->back();
        }
        $user->fill(['banned' => true])->save();
        return redirect()->back();
    }

    public function delete($user)
    {
        if ($user->id == 1) {
            Session::flash('alert',
                'You cannot delete the superuser account.');
            return redirect()->back();
        }
        $path = storage_path() . '/uploads/';
        foreach ($user->uploads as $upload) {
            $filePath = $path . $upload->name;
            if (File::isFile($filePath)) {
                File::delete($filePath);
            }
        }
        $user->forceDelete();
        return redirect()->back();
    }

    public function unban($user)
    {
        $user->fill(['banned' => false])->save();
        return redirect()->back();
    }

    public function uploads($user)
    {
        $uploads = Upload::where('user_id', $user->id)->orderBy('created_at', 'desc')->paginate(15);
        return view('admin.uploads', compact('uploads', 'user'));
    }

    public function enable($user)
    {
        $user->fill(['enabled' => true])->save();
        Mail::queue(['text' => 'emails.user.account_approved'], ['user' => $user], function($message) use ($user)
        {
            $message->from(env('SITE_EMAIL_FROM'), env('SITE_NAME'));
            $message->subject(sprintf("[%s] Account Approved", env('DOMAIN')));
            $message->to($user->email);
        });
        return redirect()->back();
    }
}
{'fraction_non_alphanumeric': 0.18254319893664156, 'fraction_numerical': 0.003987594151528578, 'mean_word_length': 2.238880918220947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 67, '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': '2479683', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1282, 'n_words': 275}