<?php

namespace App\Nova;

use App\Nova\Actions\EditHomeMedia;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\File;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Image;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\URL;
use Laravel\Nova\Http\Requests\NovaRequest;
use Mostafaznv\NovaVideo\Video;

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

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

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'id',
    ];

    /**
     * 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(),
            Text::make('En Slogan','slogan_en'),
            Text::make('Ar Slogan','slogan_ar'),
            Text::make('En Slogan Sub Text','sub_slogan_en'),
            Text::make('Ar Slogan Sub Text','sub_slogan_ar'),
            Text::make('Ar Services Header','services_header_ar'),
            Text::make('En Services Header','services_header_en'),
            Text::make('Ar Services Subtitle','services_subtitle_ar'),
            Text::make('En Services Subtitle','services_subtitle_en'),
            Text::make('Ar Why Muhadisin Header','why_header_en'),
            Text::make('En Why Muhadisin Header','why_header_ar'),
            Text::make('Ar Why Muhadisin Subtitle','why_subtitle_en'),
            Text::make('En Why Muhadisin Subtitle','why_subtitle_ar'),
            Text::make('Ar How it works Header','how_header_ar'),
            Text::make('En How it works Header','how_header_en'),
            Text::make('Ar How it works Subtitle','how_subtitle_ar'),
            Text::make('En How it works Subtitle','how_subtitle_en'),
            Text::make('Ar Need Something Header','need_something_header_ar'),
            Text::make('En Need Something Header','need_something_header_en'),
            Text::make('Ar Need Something Subtitle','need_something_subtitle_ar'),
            Text::make('En Need Something Subtitle','need_something_subtitle_en'),
            Image::make('Slogan image','slogan_image_url')->thumbnail(function ($url){
                return $url;
            })->displayUsing(
                function ($url){
                    return $url;
                }
            )->preview(function ($url){
                return $url;
            })->hideWhenCreating()->hideWhenUpdating(),
            Video::make(trans('Video'), 'video_url', 'media')
                ->rules('file', 'max:150000', 'mimes:mp4', 'mimetypes:video/mp4')
                ->creationRules('required')
                ->updateRules('nullable')->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 [
            EditHomeMedia::make(),
        ];
    }
}
