<commit_before><?php

namespace App\Http\Controllers;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Input;

class UserController extends Controller {
    var $occupations = [
        '' => '(Select one)',
        'Student' => 'Student',
        'Medic' => 'Medic',
        'Driver' => 'Driver',
        'Software Developer' => 'Software Developer'
    ];
    
    public function index() {
        $users = User::orderBy('created_at', 'asc')->get();

        return view('user-index', [
            'users' => $users
        ]);
    }
    
    public function create() {
        return view('user-create', [
            'occupations' => $this->occupations
        ]);
    }
    
    public function store(Request $request) {
        $validator = validator::make($request->all(), [
            'name' => 'required|max:255',
            'email' => 'required|email',
            'birthday' => 'required|date_format:Y-m-d',
            'occupation' => 'required'
        ]);

        if ($validator->fails()) {
            return redirect('/user/create')
                ->withInput()
                ->withErrors($validator);
        }

        $user = new User;

        $user->name = $request->name;
        $user->email = $request->email;
        $user->birthday = $request->birthday;
        $user->occupation = $request->occupation;
        $user->notes = $request->notes;

        $user->save();

        return redirect('/user');
    }<commit_msg>implemented unique email validation<commit_after><?php

namespace App\Http\Controllers;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Input;

class UserController extends Controller {
    var $occupations = [
        '' => '(Select one)',
        'Student' => 'Student',
        'Medic' => 'Medic',
        'Driver' => 'Driver',
        'Software Developer' => 'Software Developer'
    ];
    
    public function index() {
        $users = User::orderBy('created_at', 'asc')->get();

        return view('user-index', [
            'users' => $users
        ]);
    }
    
    public function create() {
        return view('user-create', [
            'occupations' => $this->occupations
        ]);
    }
    
    public function store(Request $request) {
        $validator = validator::make($request->all(), [
            'name' => 'required|max:255',
            'email' => 'required|email|unique:users',
            'birthday' => 'required|date_format:Y-m-d',
            'occupation' => 'required'
        ]);

        if ($validator->fails()) {
            return redirect('/user/create')
                ->withInput()
                ->withErrors($validator);
        }

        $user = new User;

        $user->name = $request->name;
        $user->email = $request->email;
        $user->birthday = $request->birthday;
        $user->occupation = $request->occupation;
        $user->notes = $request->notes;

        $user->save();

        return redirect('/user');
    }
{'fraction_non_alphanumeric': 0.16238503013003489, 'fraction_numerical': 0.0019029495718363464, 'mean_word_length': 2.0982318271119844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6631966', 'n_tokens_mistral': 911, 'n_tokens_neox': 899, 'n_words': 171}