Пример #1
0
 public function delete()
 {
     $directoryPath = $this->getDirectoryPath();
     $iterator = new \DirectoryIterator($directoryPath);
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->isDir() && !$fileinfo->isDot()) {
             $file = $directoryPath . $fileinfo->getFilename() . '/' . $this->filename;
             if (is_file($file)) {
                 unlink($file);
             }
         }
     }
     $main_file = $directoryPath . $this->filename;
     if (is_file($main_file)) {
         unlink($main_file);
     }
     parent::delete();
 }
Пример #2
0
 public function save(array $options = array())
 {
     if (empty($this->id)) {
         $max_sort = DB::table($this->table)->where('parent', !empty($this->parent) ? $this->parent : 0)->where('deleted_at', null)->max('sort');
         $this->sort = is_numeric($max_sort) ? $max_sort + 1 : 0;
     }
     if (!empty($this->element_id)) {
         if (empty($this->module)) {
             $this->element_id = 0;
         } else {
             $module = 'Ognestraz\\Admin\\Models\\' . ucfirst($this->module);
             $element = $module::find($this->element_id);
             if (!empty($element->id)) {
                 $this->path = $element->path;
             }
         }
     }
     return parent::save($options);
 }
Пример #3
0
 public function delete()
 {
     parent::delete();
 }