public static function post_subitems($node, $single_model, $parent_name, $parent_id, $fields, $parameters = [])
 {
     if (request()->has($single_model . '_id')) {
         $model = \FuncNode::node_check_model($node);
         $model->where($parent_name, $parent_id)->whereNotIn('id', request()->input($single_model . '_id'))->delete();
         foreach (request()->input($single_model . '_id') as $key => $subid) {
             $model = \FuncNode::node_check_model($node);
             $validated = false;
             $fields_array = [];
             foreach ($fields as $field) {
                 $field_input = request()->input($single_model . '_' . $field->name);
                 if (isset($field_input[$key])) {
                     $fields_array[$field->name] = $field_input[$key];
                 }
             }
             if ($subid && $subid != 0) {
                 if (Validator::make($fields_array, \FuncNode::node_check_rules($node, 'create'))->passes()) {
                     $subitem = $model->find($subid);
                     $validated = true;
                 }
             } else {
                 if (Validator::make($fields_array, \FuncNode::node_check_rules($node, 'edit'))->passes()) {
                     $validated = true;
                     $subitem = $model;
                     $subitem->{$parent_name} = $parent_id;
                 }
             }
             if ($validated == true) {
                 foreach ($fields as $field) {
                     $field_name = $field->name;
                     $subinput = NULL;
                     $field_input = request()->input($single_model . '_' . $field->name);
                     if (isset($field_input[$key])) {
                         $subinput = $field_input[$key];
                     }
                     $subitem = \FuncNode::put_data_field($subitem, $field, $subinput);
                 }
                 $subitem->save();
             }
         }
         return true;
     }
     return false;
 }
 public static function get_list($object, $single_model, $extra = [])
 {
     $module = $object->module;
     $node = \Solunes\Master\App\Node::where('name', $single_model)->first();
     $model = \FuncNode::node_check_model($node);
     if (\Gate::denies('node-admin', ['list', $module, $node, 'list'])) {
         return \Login::redirect_dashboard('no_permission');
     }
     $array = ['module' => $module, 'node' => $node, 'model' => $single_model, 'i' => NULL, 'filter_category' => 'admin', 'filter_category_id' => '0', 'filter_type' => 'field', 'filter_node' => $node->name, 'dt' => 'form', 'id' => NULL, 'parent' => NULL, 'action_fields' => ['create', 'edit', 'delete']];
     if ($action_field = $node->node_extras()->where('type', 'action_field')->first()) {
         $array['action_fields'] = json_decode($action_field->value_array, true);
     }
     if (request()->has('parent_id')) {
         $id = request()->input('parent_id');
         $array['id'] = $id;
         $items = $model->whereHas('parent', function ($q) use($id) {
             $q->where('id', $id);
         });
     } else {
         $items = $model->whereNotNull('id');
     }
     if ($node) {
         if ($node->soft_delete == 1 && request()->has('view-trash') && request()->input('view-trash') == 'true') {
             $items->onlyTrashed();
         }
         if ($node->translation) {
             $items->with('translations');
         }
         if ($node->parent) {
             $array['parent'] = $node->parent->name;
         }
         if (request()->has('download-excel')) {
             $display_fields = ['show', 'excel'];
         } else {
             $display_fields = ['show'];
         }
         $array['fields'] = $node->fields()->whereIn('display_list', $display_fields)->where('type', '!=', 'field')->with('translations')->get();
         $relation_fields = $node->fields()->whereIn('display_list', $display_fields)->where('type', 'relation')->get();
         if (count($relation_fields) > 0) {
             foreach ($relation_fields as $relation) {
                 $sub_node = \Solunes\Master\App\Node::where('name', str_replace('_', '-', $relation->value))->first();
                 if ($sub_node->translation) {
                     $items = $items->with([$relation->trans_name, $relation->trans_name . '.translations']);
                 } else {
                     $items = $items->with($relation->trans_name);
                 }
             }
         }
     }
     $array = \AdminList::filter_node($array, $node, $model, $items, 'admin');
     $items = $array['items'];
     $graphs = $node->node_extras()->whereIn('type', ['graph', 'parent_graph'])->get();
     $array = \AdminList::graph_node($array, $node, $model, $items, $graphs);
     $items_relations = $node->fields()->where('name', '!=', 'parent_id')->whereIn('type', ['relation', 'child', 'subchild'])->get();
     if (count($items_relations) > 0) {
         foreach ($items_relations as $item_relation) {
             $items->with($item_relation->trans_name);
         }
     }
     $array['items'] = $items->get();
     if ($node->translation == 1) {
         $array['langs'] = \Solunes\Master\App\Language::get();
     } else {
         $array['langs'] = [];
     }
     if (request()->has('download-excel')) {
         return AdminList::generate_query_excel($array);
     } else {
         return view('master::list.general-list', $array);
     }
 }