コード例 #1
0
 /**
  * Handle the command.
  */
 public function handle()
 {
     $tree = $this->builder->getTree();
     $model = $this->builder->getModel();
     /**
      * If the model is already instantiated
      * then use it as is.
      */
     if (is_object($model)) {
         $tree->setModel($model);
         return;
     }
     /**
      * If no model is set, try guessing the
      * model based on best practices.
      */
     if (!$model) {
         $parts = explode('\\', str_replace('TreeBuilder', 'Model', get_class($this->builder)));
         unset($parts[count($parts) - 2]);
         $model = implode('\\', $parts);
         $this->builder->setModel($model);
     }
     /**
      * If the model is not set then skip it.
      */
     if (!class_exists($model)) {
         return;
     }
     /**
      * Set the model on the tree!
      */
     $tree->setModel(app($model));
 }