<?php
namespace Themes\ekmal;

use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use Modules\Vod\Models\VideoTag;

class ThemeWidgets
{

    /*
    |--------------------------------------------------------------------------
    | Template options field for ThemeManager
    |--------------------------------------------------------------------------
    |
    |
    | Any fields defined here will show up after the standard page fields:
    | - select template
    | - Theme name (only seen by admins)
    */

    public function widget_banner_with_icon()
    {
        CRUD::addFields([
            [   // repeatable
                'name'  => 'slides',
                'label' => 'بنرها',
                'fake'  => true,
                'tab'          => 'محتوا',
                'type'  => 'repeatable',
                'subfields' => [ // also works as: "fields"
                    [
                        'name' => 'image',
                        'label' => 'تصویر',
                        'type'  => 'browse',
                        'fake'  => true,
                    ],
                    [
                        'name' => 'link',
                        'prefix' => '<i class="la la-link la-lg"></i>',
                        'label' => 'لینک',
                        'tab'          => 'محتوا',
                        'fake'  => true,
                    ],
                    [
                        'name' => 'alt',
                        'label' => 'متن تصویر',
                        'tab'          => 'محتوا',
                        'fake'  => true,
                    ],
                ],

                // optional
                'new_item_label'  => 'افزودن بنر', // customize the text of the button
                'init_rows' => 0, // number of empty rows to be initialized, by default 1
                // 'min_rows' => 2, // minimum rows allowed, when reached the "delete" buttons will be hidden
                'max_rows' => 12, // maximum rows allowed, when reached the "new item" button will be hidden
            ]
        ]);
    }

    public function widget_videos_slider()
    {
        $tags = VideoTag::all()->pluck('title', 'id');
        CRUD::addFields([
            [
                'name' => 'main_title',
                'label' => 'عنوان',
                'prefix' =>'<i class="la la-pencil la-lg"></i>',
                'tab'          => 'محتوا',
                'fake'  => true,
                'store_in' => 'extras_translatable',
                'translatable' => true,
            ],[
                'name' => 'main_description',
                'label' => 'توضیح مختصر',
                'prefix' =>'<i class="la la-pencil"></i>',
                'tab'          => 'محتوا',
                'fake'  => true,
                'store_in' => 'extras_translatable',
                'wrapper'      => ['class'  => "form-group col-md-6"],
                'translatable' => true,
            ],
            [   // select2_from_array
                'name'        => 'title_position',
                'label'       => "جایگاه عنوان",
                'type'        => 'select2_from_array',
                'wrapper'      => ['class'  => "form-group col-md-6"],
                'options'     => [
                    'right' => 'راست',
                    'center' => 'وسط'
                ],
                'allows_null' => false,
                'tab'          => 'محتوا',
                'fake'  => true,
//                'allows_multiple' => true, // OPTIONAL; needs you to cast this to array in your model;
            ],
            [
                'name'   => 'button_label',
                'prefix' =>'<i class="la la-pencil la-lg"></i>',
                'label'  => 'متن دکمه',
                'wrapper'      => ['class'  => "form-group col-md-6"],
                'attributes'   => ['placeholder' => 'متن'],
                'tab'          => 'محتوا',
                'fake'  => true,
                'store_in' => 'extras_translatable',
                'translatable' => true,
            ],
            [
                'name' => 'button_link',
                'prefix' => '<i class="la la-link la-lg"></i>',
                'attributes'   => ['placeholder' => 'لینک'],
                'label' => 'لینک دکمه',
                'wrapper'      => ['class'  => "form-group col-md-6"],
                'tab'          => 'محتوا',
                'fake'  => true,
            ],
            [   // select2_from_array
                'name'        => 'tags',
                'label'       => "تگ ها",
                'type'        => 'select2_from_array',
                'options'     => $tags,
                'allows_null' => false,
                'tab'          => 'محتوا',
                'fake'  => true,
                 'allows_multiple' => true, // OPTIONAL; needs you to cast this to array in your model;
            ]
        ]);
    }

    public function widget_videos_slider_1()
    {
        $this->widget_videos_slider();
    }

    public function widget_videos_slider_2()
    {
        $this->widget_videos_slider();
    }

    public function widget_videos_slider_3()
    {
        $this->widget_videos_slider();
    }

    public function widget_videos_slider_4()
    {
        $this->widget_videos_slider();
    }

    public function widget_videos_slider_5()
    {
        $this->widget_videos_slider();
    }

    public function widget_videos_slider_6()
    {
        $this->widget_videos_slider();
    }

    public function widget_videos_slider_7()
    {
        $this->widget_videos_slider();
    }

    public function widget_videos_slider_8()
    {
        $this->widget_videos_slider();
    }

    public function widget_videos_slider_9()
    {
        $this->widget_videos_slider();
    }

    public function widget_videos_slider_10()
    {
        $this->widget_videos_slider();
    }

}
