예제 #1
0
 static function treeItems($route_show, $id, $indent, array $params = [], $selected = null)
 {
     if ($indent < 15) {
         $items = Folder::withTrashed()->whereFolderId($id)->orderBy('order')->orderBy('name')->get();
         if ($items->count() > 0) {
             static::$treeResult .= PHP_EOL . '<ul style="padding-left: 15px;">';
             foreach ($items as $item) {
                 if ($item->id == $selected) {
                     if ($item->trashed()) {
                         static::$treeResult .= PHP_EOL . '<li><strong><del>' . $item->name . '</strong></del>';
                     } else {
                         static::$treeResult .= PHP_EOL . '<li><strong>' . $item->name . '</strong>';
                     }
                 } else {
                     if ($item->trashed()) {
                         static::$treeResult .= PHP_EOL . '<li><del>' . link_to_route($route_show, $item->name, array_merge(['id' => $item->id], $params)) . '</del>';
                     } else {
                         static::$treeResult .= PHP_EOL . '<li>' . link_to_route($route_show, $item->name, array_merge(['id' => $item->id], $params));
                     }
                 }
                 static::treeItems($route_show, $item->id, $indent + 1, $params, $selected);
                 static::$treeResult .= PHP_EOL . '</li>';
             }
             static::$treeResult .= PHP_EOL . '</ul>';
         }
     }
 }
 protected function cleanRoot(DeleteRequest $request)
 {
     $root = Folder::withTrashed()->find(Folder::ROOT_FOLDER);
     if ($root) {
         foreach ($root->children()->get() as $rooted) {
             foreach ($rooted->children()->get() as $child) {
                 $this->setRoot($child, $rooted->id, 1);
             }
         }
     }
     return redirect(route($this->index_route));
 }