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); } }