<commit_before><?php namespace Modules\Menu\Repositories\Eloquent;

use Illuminate\Support\Facades\DB;
use Laracasts\Commander\Events\EventGenerator;
use Laracasts\Commander\Events\DispatchableTrait;
use Modules\Menu\Events\MenuItemWasCreated;
use Modules\Menu\Repositories\MenuItemRepository;
use Modules\Core\Repositories\Eloquent\EloquentBaseRepository;

class EloquentMenuItemRepository extends EloquentBaseRepository implements MenuItemRepository
{
    use EventGenerator, DispatchableTrait;

    public function create($data)
    {
        $menuItem = $this->model->create($data);

        $this->raise(new MenuItemWasCreated($menuItem));
        $this->dispatchEventsFor($this);

        return $menuItem;
    }

    public function update($menuItem, $data)
    {
        $menuItem->update($data);

        return $menuItem;
    }

    public function rootsForMenu($menuId)
    {
        return $this->model->whereMenuId($menuId)->with('translations')->orderBy('position')->get();
    }

    /**
     * Get Items to build routes
     *
     * @return Array
     */
    public function getForRoutes()
    {
        $menuitems = DB::table('menus')
            ->select(
                'primary',
                'menuitems.id',
                'menuitems.parent_id',
                'menuitems.module_name',
                'menuitem_translations.uri',
                'menuitem_translations.locale'
            )
            ->join('menuitems', 'menus.id', '=', 'menuitems.menu_id')
            ->join('menuitem_translations', 'menuitems.id', '=', 'menuitem_translations.menuitem_id')
            ->where('uri', '!=', '')
            ->where('module_name', '!=', '')
            ->where('status', '=', 1)
            ->where('primary', '=', 1)
            ->orderBy('module_name')
            ->get();
<commit_msg>Add a status check on the menu items<commit_after><?php namespace Modules\Menu\Repositories\Eloquent;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\DB;
use Laracasts\Commander\Events\EventGenerator;
use Laracasts\Commander\Events\DispatchableTrait;
use Modules\Menu\Events\MenuItemWasCreated;
use Modules\Menu\Repositories\MenuItemRepository;
use Modules\Core\Repositories\Eloquent\EloquentBaseRepository;

class EloquentMenuItemRepository extends EloquentBaseRepository implements MenuItemRepository
{
    use EventGenerator, DispatchableTrait;

    public function create($data)
    {
        $menuItem = $this->model->create($data);

        $this->raise(new MenuItemWasCreated($menuItem));
        $this->dispatchEventsFor($this);

        return $menuItem;
    }

    public function update($menuItem, $data)
    {
        $menuItem->update($data);

        return $menuItem;
    }

    public function rootsForMenu($menuId)
    {
        return $this->model->whereHas('translations', function (Builder $q) {
            $q->where('status', 1);
            $q->where('locale', App::getLocale());
        })->with('translations')->whereMenuId($menuId)->orderBy('position')->get();
    }

    /**
     * Get Items to build routes
     *
     * @return Array
     */
    public function getForRoutes()
    {
        $menuitems = DB::table('menus')
            ->select(
                'primary',
                'menuitems.id',
                'menuitems.parent_id',
                'menuitems.module_name',
                'menuitem_translations.uri',
                'menuitem_translations.locale'
            )
            ->join('menuitems', 'menus.id', '=', 'menuitems.menu_id')
            ->join('menuitem_translations', 'menuitems.id', '=', 'menuitem_translations.menuitem_id')
            ->where('uri', '!=', '')
            ->where('module_name', '!=', '')
            ->where('status', '=', 1)
            ->where('primary', '=', 1)
            ->orderBy('module_name')
            ->get();

{'fraction_non_alphanumeric': 0.14443587766640967, 'fraction_numerical': 0.0012850167052171678, 'mean_word_length': 2.5575868372943327, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '1785458', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1151, 'n_words': 177}