/**
  *
  */
 public function __construct()
 {
     $this->middleware('author');
     /*
      * check the ROOT_ITEM with a null parent
      * check all items with null parent to be ROOT_ITEM owned
      */
     $root = Folder::withTrashed()->find(Folder::ROOT_FOLDER);
     if (!$root) {
         $root = new Folder();
         $root->name = '/';
         $root->folder_id = null;
         $root->root_id = null;
         $root->user_id = User::ROOT_USER;
         $root->private = false;
         $root->save();
         $root->id = Folder::ROOT_FOLDER;
         $root->save();
     } else {
         if ($root->trashed()) {
             $root->restore();
         }
         if ($root->folder_id != null || $root->root_id != null || $root->user_id != User::ROOT_USER) {
             $root->root_id = null;
             $root->folder_id = null;
             $root->user_id = User::ROOT_USER;
             $root->save();
         }
     }
     Folder::withTrashed()->whereFolderId(null)->where('id', '<>', Folder::ROOT_FOLDER)->update(['folder_id' => Folder::ROOT_FOLDER]);
     if (Auth::check()) {
         $root = Folder::withTrashed()->whereFolderId(Folder::ROOT_FOLDER)->whereUserId(Auth::user()->id)->first();
         if (!$root) {
             $root = new Folder();
             $root->name = Auth::user()->display_name;
             $root->folder_id = Folder::ROOT_FOLDER;
             $root->root_id = Folder::ROOT_FOLDER;
             $root->user_id = Auth::user()->id;
             $root->private = true;
             $root->description = Auth::user()->display_name . '\'s Private folder';
             $root->save();
         }
         $this->author_folder = $root;
     }
 }