/**
  * set file options
  *
  * @param \Illuminate\Http\Request $request
  * @param array $params [ ['column_name' => 'option_name'] ]
  * @return void
  */
 protected function setToFileOptions($request, $params)
 {
     $module = getModule(get_called_class());
     $model = getModelSlug(get_called_class());
     $options = [];
     $elfinders = [];
     foreach ($params as $column => $optionName) {
         $isGroup = is_integer($column) && is_array($optionName) && isset($optionName['group']);
         $configName = $isGroup || isset($optionName['column']) ? $optionName['config'] : $optionName;
         $columnParts = explode('.', $isGroup || isset($optionName['column']) ? $optionName['column'] : $column);
         $inputName = count($columnParts) > 1 ? $columnParts[1] : $columnParts[0];
         $inputName = isset($optionName['inputPrefix']) ? $optionName['inputPrefix'] . $inputName : $inputName;
         $fullColumn = implode('.', $columnParts);
         // options set edilir
         if ($isGroup && (is_array($request->file($optionName['group'])) && $request->file("{$optionName['group']}.{$column}.{$inputName}") || $request->has("{$optionName['group']}.{$column}.{$inputName}")) || (is_array($request->file($inputName)) && $request->file($inputName)[0] || !is_array($request->file($inputName)) && $request->file($inputName)) || $request->has($inputName)) {
             $moduleOptions = config("{$module}.{$model}.uploads.{$configName}");
             // if column is array
             if (is_array($moduleOptions['column'])) {
                 $moduleOptions['column'] = $moduleOptions['column'][$inputName];
             }
             // is group
             if ($isGroup) {
                 $moduleOptions['group'] = $optionName['group'];
             }
             // add some data
             if ($isGroup || isset($optionName['column'])) {
                 $moduleOptions['index'] = $column;
                 if (isset($optionName['changeThumb'])) {
                     $moduleOptions['changeThumb'] = $optionName['changeThumb'];
                 }
                 if (isset($optionName['changeToHasOne'])) {
                     $moduleOptions['changeToHasOne'] = $optionName['changeToHasOne'];
                 }
                 if (isset($optionName['is_reset'])) {
                     $moduleOptions['is_reset'] = $optionName['is_reset'];
                 }
                 $moduleOptions['add_column'] = isset($optionName['add_column']) ? $optionName['add_column'] : [];
                 $moduleOptions['inputPrefix'] = isset($optionName['inputPrefix']) ? $optionName['inputPrefix'] : [];
             }
             array_push($options, $moduleOptions);
         }
         // elfinder mi belirtilir
         if ($isGroup && $request->has("{$optionName['group']}.{$column}.{$inputName}") || $request->has($inputName) && !$request->file($inputName)[0]) {
             $elfinderOption = $isGroup || isset($optionName['column']) ? ['index' => count($options) - 1, 'column' => $optionName['column']] : $fullColumn;
             array_push($elfinders, $elfinderOption);
         }
     }
     $this->setFileOptions($options);
     foreach ($elfinders as $elfinder) {
         $this->setElfinderToOptions($elfinder);
     }
 }
 /**
  * get trans and routes params
  *
  * @param array $models
  * @param array $columns
  * @return array
  */
 private function getTransRouteParam($models, $columns)
 {
     $result = ['trans' => [], 'route' => []];
     if (empty($models) && empty($columns)) {
         return $result;
     }
     for ($i = 0; $i < count($models); $i++) {
         $module_name = getModelSlug($models[$i]);
         // eğer route_name ikinci ve üçüncü parametresi aynı ise; module_name önüne parent_ ekle
         // çünkü ikisi aynı model ve iç içe ilişkisi var => admin.document_category.document_category.show gibi
         $route_name_parts = explode('.', $this->route_name);
         $module_name = !is_null($models[$i]) && $route_name_parts[1] === $route_name_parts[2] ? 'parent_' . $module_name : $module_name;
         $result['trans'][$module_name] = $models[$i]->{$columns}[$i];
         // sadece birinci için id eklenir
         if ($i === 0) {
             $result['route']['id'] = $models[$i]->id;
         }
     }
     return $result;
 }
 /**
  * return redirect url path
  *
  * @param string $path
  * @param boolean $isUpdate
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 protected function redirectRoute($path, $isUpdate = false)
 {
     $indexPos = strpos($path, 'index');
     $dotPos = strpos($path, '.');
     $slug = getModelSlug($this->model);
     // İlişkisiz yalın sayfalardan index hariç
     if ($indexPos === false && $dotPos === false) {
         return redirect(lmbRoute("admin.{$slug}.{$path}", ['id' => $this->model->id]));
     }
     // İlişkili sayfalardan index hariç
     if ($indexPos === false) {
         $id = $isUpdate && !is_null($this->model->category_id) && is_null($this->relatedId) ? $this->model->category_id : ($isUpdate && is_null($this->relatedId) ? $this->model->categories->first()->id : $this->relatedId);
         return redirect(lmbRoute("admin.{$path}", ['id' => $id, $this->routeRegex => $this->model->id]));
     }
     // İlişkisiz sayfalardan index
     if ($dotPos === false) {
         return redirect(lmbRoute("admin.{$slug}.{$path}"));
     }
     // İlişkili sayfalardan index
     return redirect(lmbRoute("admin.{$path}", ['id' => $this->relatedId]));
 }
 /**
  * get default urls for Datatables
  *
  * @param \Illuminate\Database\Eloquent\Model $model
  * @return array
  */
 private function getDefaultUrls($model)
 {
     $slug = getModelSlug($model);
     return ['details' => lmbRoute("api.{$slug}.detail", ['id' => $model->id]), 'fast_edit' => lmbRoute("api.{$slug}.fastEdit", ['id' => $model->id]), 'edit' => lmbRoute("api.{$slug}.update", ['id' => $model->id]), 'destroy' => lmbRoute("api.{$slug}.destroy", ['id' => $model->id]), 'show' => lmbRoute("admin.{$slug}.show", ['id' => $model->id])];
 }
@if($category)

<?php 
$relation = $model ? getModelSlug($model) . 's' : '';
?>

@foreach($category->ancestorsAndSelf()->extrasWithValues($model)->get() as $ancestorCategory)

    @foreach($ancestorCategory->extras as $extra)

        {{-- Extra Column --}}
        <div class="form-group">
            <label class="control-label"> {{ $extra->name_uc_first }} </label>

            {{-- Input Element --}}
            @if($extra->type === 'date')
                <div class="input-group date date-picker" data-date-format="dd.mm.yyyy">
                    {!! Form::text( "extras[{$extra->id}][value]", $model && ! is_null($extra->$relation->first()) ? $extra->$relation->first()->pivot->value : null, [
                        'class'         => 'form-control form-filter',
                        'placeholder'   => $extra->name_uc_first,
                        'readonly'      => true
                    ]) !!}
                    <span class="input-group-btn">
                        <button class="btn green btn-outline" type="button">
                            <i class="fa fa-calendar"></i>
                        </button>
                    </span>
                </div>
            @else
                {!! Form::text( "extras[{$extra->id}][value]", $model && ! is_null($extra->$relation->first()) ? $extra->$relation->first()->pivot->value : null, [
                    'class'         => 'form-control form-control-solid placeholder-no-fix',
 /**
  * get extra column datas with model values
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @param $model
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeExtrasWithValues($query, $model)
 {
     $modelSlug = $model ? getModelSlug($model) : false;
     return $query->with(['extras' => function ($query) use($model, $modelSlug) {
         if (!$model) {
             return $query;
         }
         return $query->with(["{$modelSlug}s" => function ($query) use($model, $modelSlug) {
             return $query->wherePivot("{$modelSlug}_id", $model->id);
         }]);
     }]);
 }