<commit_before><?php

namespace App\Http\Controllers;

use Askedio\Laravel5GoogleCalendar\Calendar;
use Auth;
use Illuminate\Http\Request;

class CalendarController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Create a calendar, redirect home.
     *
     * @return redirect
     */
    public function store(Request $request)
    {
        $_calendar = $request->input('calendar') ?: 'Bill Reminders';
        $_id = false;

        \App\GoogleCalendar\Calendar::setVar('calendar', '');
        $_calendars = \App\GoogleCalendar\Calendar::readCalendar();
        if ($_calendars->items) {
            $_found = false;
            foreach ($_calendars->items as $_cal) {
                if ($_cal->summary == $_calendar) {
                    $_id = $_cal->id;
                    break;
                }
            }
        }

        if (!$_id) {
            \App\GoogleCalendar\Calendar::setVar('calendar', 'create');
            $_results = \App\GoogleCalendar\Calendar::createCalendar([
          'summary'         => $request->input('calendar') ?: 'Bill Reminders',
          'description'     => 'Created by BillReminder',
        ]);
        // needs check if isset
        $_id = $_results->id;
        }

        if ($_id) {
            Auth::user()->calendar = $_id;
            Auth::user()->save();
        } else {
            die('shoot');
        }

        return redirect('home');
    }
}<commit_msg>Fix CalendarController<commit_after><?php

namespace App\Http\Controllers;

use Askedio\Laravel5GoogleCalendar\Calendar;
use Auth;
use Illuminate\Http\Request;

class CalendarController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Create a calendar, redirect home.
     *
     * @return redirect
     */
    public function store(Request $request)
    {
        $_calendar = $request->input('calendar') ?: 'Bill Reminders';
        $_id = false;

       Calendar::setVar('calendar', '');
        $_calendars =Calendar::readCalendar();
        if ($_calendars->items) {
            $_found = false;
            foreach ($_calendars->items as $_cal) {
                if ($_cal->summary == $_calendar) {
                    $_id = $_cal->id;
                    break;
                }
            }
        }

        if (!$_id) {
           Calendar::setVar('calendar', 'create');
            $_results =Calendar::createCalendar([
          'summary'         => $request->input('calendar') ?: 'Bill Reminders',
          'description'     => 'Created by BillReminder',
        ]);
        /* TO-DO: Needs proper checks. */
        $_id = $_results->id;
        }

        if ($_id) {
            Auth::user()->calendar = $_id;
            Auth::user()->save();
        } else {
            die('shoot');
        }

        return redirect('home');
    }
}
{'fraction_non_alphanumeric': 0.144613393723714, 'fraction_numerical': 0.0006470397929472663, 'mean_word_length': 1.7194371152154793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '6337833', 'n_tokens_mistral': 864, 'n_tokens_neox': 848, 'n_words': 175}