<commit_before><?php

namespace Zeropingheroes\Lanager\Http\Controllers;

use Zeropingheroes\Lanager\Lan;

class CurrentLanController extends Controller
{
    /**
     * @var \Zeropingheroes\Lanager\Lan
     */
    protected $lan;

    /**
     * Determine the current LAN
     */
    public function __construct()
    {
        $this->lan = Lan::happeningNow()->where('published', 1)->first()                       // LAN happening now
                  ?? Lan::future()->where('published', 1)->orderBy('start', 'asc')->first()    // Closest future LAN
                  ?? Lan::past()->where('published', 1)->orderBy('end', 'desc')->first();      // Most recently ended past LAN

        // If there are no LANs, go to a 404 page
        if (!$this->lan) {
            abort(404);
        }
    }

    /**
     * Redirect to current LAN's page
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function show()
    {
        return redirect()->route('lans.show', $this->lan);
    }

    /**
     * Redirect to current LAN's guides index
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function guides()
    {
        return redirect()->route('lans.guides.index', $this->lan);
    }

    /**
     * Redirect to current LAN's events index
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function events()
    {
        return redirect()->route('lans.events.index', $this->lan);
    }

    /**
     * Redirect to current LAN's events schedule
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function schedule()
    {
        return redirect()->route('lans.events.index', ['lan' => $this->lan, 'schedule']);
    }

    /**
     * Redirect to current LAN's attendees index
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function users()
    {
        return redirect()->route('lans.attendees.index', $this->lan);
    }

    /**
     * Redirect to current LAN's awarded achievements
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function userAchievements()
    {
        return redirect()->route('lans.user-achievements.index', $this->lan);
    }
}
<commit_msg>Redirect to LAN index page if no LANs in database<commit_after><?php

namespace Zeropingheroes\Lanager\Http\Controllers;

use Zeropingheroes\Lanager\Lan;

class CurrentLanController extends Controller
{
    /**
     * @var \Zeropingheroes\Lanager\Lan
     */
    protected $lan;

    /**
     * Determine the current LAN
     */
    public function __construct()
    {
        $this->lan = Lan::happeningNow()->where('published', 1)->first()                       // LAN happening now
                  ?? Lan::future()->where('published', 1)->orderBy('start', 'asc')->first()    // Closest future LAN
                  ?? Lan::past()->where('published', 1)->orderBy('end', 'desc')->first();      // Most recently ended past LAN

        // If there are no LANs, go to the LAN index page
        if (!$this->lan) {
            redirect()->route('lans.index')->send();
        }
    }

    /**
     * Redirect to current LAN's page
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function show()
    {
        return redirect()->route('lans.show', $this->lan);
    }

    /**
     * Redirect to current LAN's guides index
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function guides()
    {
        return redirect()->route('lans.guides.index', $this->lan);
    }

    /**
     * Redirect to current LAN's events index
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function events()
    {
        return redirect()->route('lans.events.index', $this->lan);
    }

    /**
     * Redirect to current LAN's events schedule
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function schedule()
    {
        return redirect()->route('lans.events.index', ['lan' => $this->lan, 'schedule']);
    }

    /**
     * Redirect to current LAN's attendees index
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function users()
    {
        return redirect()->route('lans.attendees.index', $this->lan);
    }

    /**
     * Redirect to current LAN's awarded achievements
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function userAchievements()
    {
        return redirect()->route('lans.user-achievements.index', $this->lan);
    }
}

{'fraction_non_alphanumeric': 0.14830414542230105, 'fraction_numerical': 0.002660164043449346, 'mean_word_length': 2.1333333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '7311227', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1299, 'n_words': 286}