classes/Controllers/Elements.php
public function index($locale = null, $tab = null)
    {
        // If there are no locales, treat the first argument as the tab
        if (!($locales = Config::get('decoy.site.locales')) || empty($locales)) {
            $tab = $locale;
            $locale = null;

        // Otherwise, set a default locale if none was specified
        } elseif (!$locale) {
            $locale = Decoy::defaultLocale();
        }

        // Get all the elements for the current locale
        $elements = app('decoy.elements')->localize($locale)->hydrate(true);

        // If the user has customized permissions, filter the elements to only the
        // allowed pages of elements.
        if ($permissions = app('decoy.user')->getPermissionsAttribute()) {
            $elements->onlyPages($permissions->elements);
        }

        // If handling a deep link to a tab, verify that the passed tab
        // slug is a real key in the data.  Else 404.
        if ($tab && !in_array($tab, $elements->pluck('page_label')
            ->map(function ($title) {
                return Str::slug($title);
            })
            ->all())) {
            App::abort(404);
        }

        // Populate form
        Former::withRules($elements->rules());
        Former::populate($elements->populate());

        // Convert the collection to models for simpler manipulation
        $elements = $elements->asModels();

        // Set the breadcrumbs NOT include the locale/tab
        app('decoy.breadcrumbs')->set([
            route('decoy::elements') => $this->title,
        ]);

        // Render the view
        return $this->populateView('decoy::elements.index', [
            'elements' => $elements,
            'locale' => $locale,
            'tab' => $tab,
        ]);
    }
public function index($locale = null, $tab = null)
    {
        // If there are no locales, treat the first argument as the tab
        if (!($locales = Config::get('decoy.site.locales')) || empty($locales)) {
            $tab = $locale;
            $locale = null;

        // Otherwise, set a default locale if none was specified
        } elseif (!$locale) {
            $locale = Decoy::defaultLocale();
        }

        // Get all the elements for the current locale
        $elements = app('decoy.elements')->localize($locale)->hydrate(true);

        // If the user has customized permissions, filter the elements to only the
        // allowed pages of elements.
        if ($permissions = app('decoy.user')->getPermissionsAttribute()) {
            $elements->onlyPages($permissions->elements);
        }

        // If handling a deep link to a tab, verify that the passed tab
        // slug is a real key in the data.  Else 404.
        if ($tab && !in_array($tab, $elements->pluck('page_label')
            ->map(function ($title) {
                return Str::slug($title);
            })
            ->all())) {
            App::abort(404);
        }

        // Populate form
        Former::withRules($elements->rules());
        Former::populate($elements->populate());

        // Convert the collection to models for simpler manipulation
        $elements = $elements->asModels();

        // Set the breadcrumbs NOT include the locale/tab
        app('decoy.breadcrumbs')->set([
            route('decoy::elements') => $this->title,
        ]);

        // Render the view
        return $this->populateView('decoy::elements.index', [
            'elements' => $elements,
            'locale' => $locale,
            'tab' => $tab,
        ]);
    }
public function index ( $ locale = null , $ tab = null ) { // If there are no locales, treat the first argument as the tab if ( ! ( $ locales = Config :: get ( 'decoy.site.locales' ) ) || empty ( $ locales ) ) { $ tab = $ locale ; $ locale = null ; // Otherwise, set a default locale if none was specified } elseif ( ! $ locale ) { $ locale = Decoy :: defaultLocale ( ) ; } // Get all the elements for the current locale $ elements = app ( 'decoy.elements' ) -> localize ( $ locale ) -> hydrate ( true ) ; // If the user has customized permissions, filter the elements to only the // allowed pages of elements. if ( $ permissions = app ( 'decoy.user' ) -> getPermissionsAttribute ( ) ) { $ elements -> onlyPages ( $ permissions -> elements ) ; } // If handling a deep link to a tab, verify that the passed tab // slug is a real key in the data.  Else 404. if ( $ tab && ! in_array ( $ tab , $ elements -> pluck ( 'page_label' ) -> map ( function ( $ title ) { return Str :: slug ( $ title ) ; } ) -> all ( ) ) ) { App :: abort ( 404 ) ; } // Populate form Former :: withRules ( $ elements -> rules ( ) ) ; Former :: populate ( $ elements -> populate ( ) ) ; // Convert the collection to models for simpler manipulation $ elements = $ elements -> asModels ( ) ; // Set the breadcrumbs NOT include the locale/tab app ( 'decoy.breadcrumbs' ) -> set ( [ route ( 'decoy::elements' ) => $ this -> title , ] ) ; // Render the view return $ this -> populateView ( 'decoy::elements.index' , [ 'elements' => $ elements , 'locale' => $ locale , 'tab' => $ tab , ] ) ; }
All elements view

@param  string                   $locale The locale to load from the DB
@param  string                   $tab    A deep link to a specific tab.  Will get processed by JS
@return Illuminate\Http\Response
All elements view