1 year ago

ERROR: Call to a member function makeChildOf() on string

Posted 1 year ago by vincej

This function comes from a maintained fork of the Baum package for creating nested sets in Laravel 5. @Bashy was happy with it, so, it must be good. I started using the original version and then gave up as it had not been maintained since 2014.

Ok, from the research I have done, I have established that the function, $child2->makeChildOf($node); does not want to see a string. However, I have no idea what else it could be? This is what I have got:


 public function createBaumCategory(Request $request){

        $category = $request->input('parent_category');  
        $value = $request->input('new_category');
        $v = Category::create(['name' =>$value ]);              // This works ! 
        $this->createCategory->addNode($value,$category);   // Passing into Model
        Flash::success(' Your new category has been created.');
        return redirect('nested_categories');



class Category extends Baum\Node
    protected $table = 'categories';
    protected $guarded = ['id'];
    public $timestamps = true;
    protected $primaryKey = 'id';

    public function addNode($value, $category)  // Both $value and $category are strings. 
        $value->makeChildOf($category);         // Fails Here. 


Any ideas ?? Many Thanks !!!

Please sign in or create an account to participate in this conversation.