{"action":"created","issue":{"url":"https://api.github.com/repos/etrepat/baum/issues/144","labels_url":"https://api.github.com/repos/etrepat/baum/issues/144/labels{/name}","comments_url":"https://api.github.com/repos/etrepat/baum/issues/144/comments","events_url":"https://api.github.com/repos/etrepat/baum/issues/144/events","html_url":"https://github.com/etrepat/baum/issues/144","id":54754196,"number":144,"title":"\"Could not resolve target node\" while creating root node","user":{"login":"broszies","id":8950709,"avatar_url":"https://avatars.githubusercontent.com/u/8950709?v=3","gravatar_id":"","url":"https://api.github.com/users/broszies","html_url":"https://github.com/broszies","followers_url":"https://api.github.com/users/broszies/followers","following_url":"https://api.github.com/users/broszies/following{/other_user}","gists_url":"https://api.github.com/users/broszies/gists{/gist_id}","starred_url":"https://api.github.com/users/broszies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broszies/subscriptions","organizations_url":"https://api.github.com/users/broszies/orgs","repos_url":"https://api.github.com/users/broszies/repos","events_url":"https://api.github.com/users/broszies/events{/privacy}","received_events_url":"https://api.github.com/users/broszies/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-19T11:41:52Z","updated_at":"2015-07-14T02:42:01Z","closed_at":"2015-02-05T10:40:37Z","body":"Hi,\r\nI noticed this issue has come up before, so its most likely my fault and not Baums, but I would apprechiate the help.\r\nOne problem might be I do not fully understand the use of the protected $scoped . if I uncomment the line, the error is \"Use of Undefined Constant - assumed id\"\r\n\r\nAlso, if I try to edit a existing Category, I get a different error: \"Value must be provided.\" \r\n\r\nAgain, appologies, since I am relatively new to laravel (and obviously not a brilliant PHP programmer). if my errors are to basic to be resolved here, please let me know ;)\r\n\r\nI will attach the Model, the form and the Controller. \r\n\r\nIf someone could point me to a repository with a wrking Baum implementation, I would very much apprechiate it.\r\n\r\nUPDATE: The category gets crated after the error, but the name does not get saved. The category then can be edited, updated and even its parent changed successfuly. I am at loss why the error shows up, though. Can it be related to using the translator?\r\n\r\nMy code:\r\n\r\n// app/models/Category.php\r\n\r\nuse Vinkla\\Translator\\TranslatorTrait;\r\nuse Baum\\Node;\r\n\r\nclass Category extends Node {\r\n\r\n  use TranslatorTrait;\r\n  /**\r\n   * Table name.\r\n   *\r\n   * @var string\r\n   */\r\n  protected $table = 'categories';\r\n  // *\r\n  // * @var array\r\n  // */\r\n  protected $guarded = array('id', 'lft', 'rgt', 'depth');\r\n  //  *\r\n  //  * @var array\r\n  //  */\r\n  // protected $scoped = array(parent_id);\r\n\r\n// All functions related to the Vinkla Translator\r\n    \r\n    // @var array\r\n\t  // MASS ASSIGNMENT -------------------------------------------------------\r\n  \t// define which attributes are mass assignable (for security)\r\n  \t// we only want these 3 attributes able to be filled\r\n    \r\n    protected $fillable = ['parent_id', 'name', 'description'];\r\n\r\n    /**\r\n     * @var string\r\n     */\r\n    protected $translator = 'CategoryTranslation';\r\n\r\n    /**\r\n     * @var array\r\n     */\r\n    protected $translatedAttributes = ['name', 'description'];\r\n\r\n-------------------\r\n\r\ncreate.blade.php\r\n\r\n@extends('layouts.default')\r\n\r\n@section('content')\r\n    <div class=\"page-header\">\r\n        <h1><?php echo trans('categories.headline_create'); ?> <small><?php echo trans('categories.subline_create'); ?></small></h1>\r\n    </div>\r\n    <div class=\"form-group\">\r\n        <form action=\"{{ action('CategoriesController@store') }}\" method=\"post\" role=\"form\">\r\n            <label for=\"title\"><?php echo trans('categories.parent'); ?></label>\r\n            <input type=\"text\" class=\"form-control\" name=\"parent_id\" />\r\n            <label for=\"title\"><?php echo trans('categories.name'); ?></label>\r\n            <input type=\"text\" class=\"form-control\" name=\"name\" />\r\n            <label for=\"title\"><?php echo trans('categories.description'); ?></label>\r\n            <input type=\"text\" class=\"form-control\" name=\"description\" />\r\n        </div>\r\n        <input type=\"submit\" value=\"<?php echo trans('categories.create'); ?>\" class=\"btn btn-primary\" />\r\n        <a href=\"{{ action('CategoriesController@index') }}\" class=\"btn btn-link\"><?php echo trans('categories.cancel'); ?></a>\r\n    </form>\r\n@stop\r\n\r\n----------------------------------\r\n\r\n<?php\r\n\r\nclass CategoriesController extends \\BaseController {\r\n\r\n\t/**\r\n\t * Display a listing of the resource.\r\n\t *\r\n\t * @return Response\r\n\t */\r\n\t\r\n  public function index()\r\n    {\r\n    // Show a listing of categories.\r\n    $categories = Category::all();\r\n    return View::make('categories.index', compact('categories'));\r\n    }\r\n\r\n\r\n\t/**\r\n\t * Show the form for creating a new resource.\r\n\t *\r\n\t * @return Response\r\n\t */\r\n\tpublic function create()\r\n    {\r\n\t\t//Show Create Categories Form\r\n    return View::make('categories.create');\r\n    }\r\n\r\n\r\n\t/**\r\n\t * Store a newly created resource in storage.\r\n\t *\r\n\t * @return Response\r\n\t */\r\n\tpublic function store()\r\n\t   {\r\n      //Store created unit in database\r\n      $input = Input::all();\r\n      $validation = Validator::make($input, Unit::$rules);\r\n        if ($validation->passes())\r\n            {\r\n            Category::create($input);\r\n            return Redirect::route('categories.index')\r\n            ->with('message', trans('categories.success_create'));\r\n            }\r\n        return Redirect::route('categories.create')\r\n            ->withInput()\r\n            ->withErrors($validation)\r\n            ->with('message', trans('validation.error'));\r\n\t   }\r\n \r\n\r\n\t/**\r\n\t * Display the specified resource.\r\n\t *\r\n\t * @param  int  $id\r\n\t * @return Response\r\n\t */\r\n\tpublic function show($id)\r\n\t{\r\n\t\t//\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Show the form for editing the specified resource.\r\n\t *\r\n\t * @param  int  $id\r\n\t * @return Response\r\n\t */\r\n\tpublic function edit($id)\r\n\t{\r\n    $category = Category::find($id);\r\n    if (is_null($category))\r\n        {\r\n        return Redirect::route('categories.index')\r\n        ->with('message', 'Category not found');\r\n        }\r\n    return View::make('categories.edit', compact('category'));\r\n  }\r\n\r\n\r\n\t/**\r\n\t * Update the specified resource in storage.\r\n\t *\r\n\t * @param  int  $id\r\n\t * @return Response\r\n\t */\r\n    public function update($id)\r\n    {\r\n      $input = Input::all();\r\n      $validation = Validator::make($input, Category::$rules);\r\n      if ($validation->passes())\r\n          {\r\n          $category = Category::find($id);\r\n          $category->update($input);\r\n          return Redirect::route('categories.index')\r\n          ->with('message', trans('categories.success_update'));\r\n          }\r\n      return Redirect::route('categories.edit', $id)\r\n      ->withInput()\r\n      ->withErrors($validation)\r\n      ->with('message', trans('validation.error'));\r\n    }\r\n\r\n\r\n\t/**\r\n\t * Remove the specified resource from storage.\r\n\t *\r\n\t * @param  int  $id\r\n\t * @return Response\r\n\t */\r\n    public function destroy($id)\r\n    {\r\n        Category::find($id)->delete();\r\n        return Redirect::route('categories.index')\r\n        ->with('message', trans('categories.success_delete'));\r\n    }\r\n}\r\n"},"comment":{"url":"https://api.github.com/repos/etrepat/baum/issues/comments/121115683","html_url":"https://github.com/etrepat/baum/issues/144#issuecomment-121115683","issue_url":"https://api.github.com/repos/etrepat/baum/issues/144","id":121115683,"user":{"login":"atorscho","id":7644596,"avatar_url":"https://avatars.githubusercontent.com/u/7644596?v=3","gravatar_id":"","url":"https://api.github.com/users/atorscho","html_url":"https://github.com/atorscho","followers_url":"https://api.github.com/users/atorscho/followers","following_url":"https://api.github.com/users/atorscho/following{/other_user}","gists_url":"https://api.github.com/users/atorscho/gists{/gist_id}","starred_url":"https://api.github.com/users/atorscho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atorscho/subscriptions","organizations_url":"https://api.github.com/users/atorscho/orgs","repos_url":"https://api.github.com/users/atorscho/repos","events_url":"https://api.github.com/users/atorscho/events{/privacy}","received_events_url":"https://api.github.com/users/atorscho/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T02:42:01Z","updated_at":"2015-07-14T02:42:01Z","body":"Exactly same problem. No idea have to fix it, but cannot disable either of them either. :/"}}