/home/bdqbpbxa/api-uniferx.goodface.com.ua/app/Nova/Layouts/Pages/CropNutritionLayout.php
<?php

namespace App\Nova\Layouts\Pages;

use Acme\MultilangText\MultilangText;
use Acme\MultilangTextarea\MultilangTextarea;
use App\Models\Country;
use App\Models\Language;
use Illuminate\Support\Facades\Storage;
use Laravel\Nova\Fields\BelongsToMany;
use Laravel\Nova\Fields\Heading;
use Laravel\Nova\Fields\Image;
use Laravel\Nova\Fields\Text;
use Whitecube\NovaFlexibleContent\Layouts\Layout;

class CropNutritionLayout extends Layout
{
    /**
     * The layout's unique identifier
     *
     * @var string
     */
    protected $name = 'title';

    /**
     * The displayed title
     *
     * @var string
     */
    protected $title = 'Content';

    protected $limit = 1;

    /**
     * Get the fields displayed by the layout.
     *
     * @return array
     */
    public function fields()
    {
        $countries = Country::query()->get();
        $languages = Language::query()->get();
        $uploadLink = route('nova.fields.upload.image');

        return [
            /** Preview */
            Heading::make(__('Preview')),
            MultilangText::make('Preview title', 'preview_title')->languages($languages)->countries($countries)->uploadLink($uploadLink)
                ->fullWidth(),
            Image::make(__('Preview image'), 'preview_image') ->disk('public')
                ->disableDownload()->deletable()->prunable()->path('posts')
                ->preview(function ($value, $disk) { return $value ? Storage::disk($disk)->url($value) : null; })
                ->thumbnail(function ($value, $disk) { return $value ? Storage::disk($disk)->url($value) : null; }),
            MultilangText::make('Preview text', 'preview_text')->languages($languages)->countries($countries)->uploadLink($uploadLink)
                ->fullWidth(),
            MultilangText::make('Preview link text', 'preview_link_text')->languages($languages)->countries($countries)->uploadLink($uploadLink)
                ->fullWidth(),

            /** First screen */
            Heading::make(__('First screen')),
            MultilangText::make('Title', 'fs_title')->languages($languages)->countries($countries)->uploadLink($uploadLink)
                ->fullWidth(),
            Image::make(__('Title background'), 'fs_title_background') ->disk('public')
                ->disableDownload()->deletable()->prunable()->path('posts')
                ->preview(function ($value, $disk) { return $value ? Storage::disk($disk)->url($value) : null; })
                ->thumbnail(function ($value, $disk) { return $value ? Storage::disk($disk)->url($value) : null; }),
            MultilangText::make('View button', 'fs_view_button')->languages($languages)->countries($countries)->uploadLink($uploadLink)
                ->fullWidth(),

            /** agricultural solutions */
            Heading::make(__('Agricultural solutions')),
            MultilangText::make('Tag', 'agricultural_tag')->languages($languages)->countries($countries)->uploadLink($uploadLink)
                ->fullWidth(),
            MultilangTextarea::make('Title', 'agricultural_title')->languages($languages)->countries($countries)->uploadLink($uploadLink)
                ->fullWidth(),

        ];
    }
}