<?php

namespace App\Nova;

use App\Nova\Actions\EditAboutImage;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Image;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
use Laravel\Nova\Http\Requests\NovaRequest;

class AboutPageContent extends Resource
{
    public static $group = 'Pages Customization';
    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = \App\Models\AboutPageContent::class;

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'slogan_en';

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'id','slogan_en','slogan_ar','main_text_en','main_text_ar','mission_text_ar','mission_text_en','vision_text_ar',
    ];

    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return array
     */
    public function fields(NovaRequest $request)
    {
        return [
            ID::make()->sortable(),
            Textarea::make('slogan_en'),
            Textarea::make('slogan_ar'),
            Textarea::make('main_text_en'),
            Textarea::make('main_text_ar'),
            Textarea::make('mission_text_ar'),
            Textarea::make('mission_text_en'),
            Textarea::make('vision_text_en'),
            Textarea::make('vision_text_ar'),
            Image::make('Main image','url')->thumbnail(function ($url){
                return $url;
            })->displayUsing(
                function ($url){
                    return $url;
                }
            )->preview(function ($url){
                return $url;
            })->hideWhenCreating()->hideWhenUpdating(),
            Image::make('Mission Icon')->thumbnail(function ($url){
                return $url;
            })->displayUsing(
                function ($url){
                    return $url;
                }
            )->preview(function ($url){
                return $url;
            })->hideWhenCreating()->hideWhenUpdating(),
            Image::make('Vision Icon')->thumbnail(function ($url){
                return $url;
            })->displayUsing(
                function ($url){
                    return $url;
                }
            )->preview(function ($url){
                return $url;
            })->hideWhenCreating()->hideWhenUpdating(),
        ];
    }

    /**
     * Get the cards available for the request.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return array
     */
    public function cards(NovaRequest $request)
    {
        return [];
    }

    /**
     * Get the filters available for the resource.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return array
     */
    public function filters(NovaRequest $request)
    {
        return [];
    }

    /**
     * Get the lenses available for the resource.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return array
     */
    public function lenses(NovaRequest $request)
    {
        return [];
    }

    /**
     * Get the actions available for the resource.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return array
     */
    public function actions(NovaRequest $request)
    {
        return [
            EditAboutImage::make(),
        ];
    }
    public static function authorizedToCreate(Request $request)
    {
        return false;
    }
}
