Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit per Layout #292

Merged
merged 4 commits into from
Sep 2, 2021
Merged

Conversation

niekbr
Copy link

@niekbr niekbr commented Sep 1, 2021

With custom layouts, set the $limit attribute to be able to not only limit the total number of groups but also limit the groups per layout type.

Example:

Flexible::make(__('Deployment'), 'deployment')
    ->addLayout(PHP::class)
    ->addLayout(Node::class)
    ->addLayout(Database::class);

With layout example:

<?php

namespace App\Nova\Flexible\Layouts;

use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Boolean;
use Whitecube\NovaFlexibleContent\Layouts\Layout;

class PHP extends Layout
{
    protected $name = 'php';
    protected $limit = 1;
    public function title()
    {
        return __('PHP');
    }
    public function fields()
    {
        return [
            Select::make(__('PHP Version'), 'php_version')
                ->options([
                    '7.4' => '7.4',
                    '8.0' => '8.0',
                ])
                ->displayUsingLabels()
                ->default('8.0'),
            Boolean::make(__('Laravel'), 'laravel')
                ->default(true),
            Boolean::make(__('Laravel Horizon'), 'laravel_horizon'),
        ];
    }
}

results in:
Screenshot from 2021-09-01 17-08-43

and after reaching the PHP limit:
Screenshot from 2021-09-01 17-08-49

Copy link
Member

@toonvandenbos toonvandenbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @niekbr,

Thanks for your PR.

To be honest, I'm working on a refactor of this package that will address a lot of issues and add some new features as well. This is one of the aspects I'm handling in the new version, but since I have no idea when I'll have time to finish nova-flexible-content v2, I'll merge this PR in the current version.

Again, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants