etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 459 forks source link

Not all my Attributes are captured in new static method #269

Closed yukopangestu closed 7 years ago

yukopangestu commented 7 years ago

I would like to insert to my database using baum create method... here is my code:

` public function createCat(Request $request) { if ($request->input('category') != '') { $getid = ProductCategory::find($request->input('category')); $result = $getid->children()->create([ 'name' => $request->input('name'), 'slug' => str_slug($request->input('name')), 'description' => $request->input('description'), ]); } else { $result = ProductCategory::create([ 'name' => $request->input('name'), 'slug' => str_slug($request->input('name')), 'description' => $request->input('description') ]); }

    if ($result) {
        return json_encode(array(
            'status' => 'SUCCESS',
        ));
    } else {
        return json_encode(array(
            'status' => 'FAILED',
        ));
    }
}

`

The problem is Baum is not recognizing my slug attribute... when I dump it, it returns:

` ProductCategory {#677

table: "product_categories"

parentColumn: "parent_id"

leftColumn: "lft"

rightColumn: "rgt"

depthColumn: "depth"

guarded: array:6 [

0 => "id"
1 => "parent_id"
2 => "lft"
3 => "rgt"
4 => "depth"
5 => "slug"

]

orderColumn: null

scoped: []

connection: null

primaryKey: "id"

perPage: 15

+incrementing: true +timestamps: true

attributes: array:2 [

"name" => "nose"
"description" => "nose"

]

original: []

relations: []

hidden: []

visible: []

appends: []

fillable: []

dates: []

dateFormat: null

casts: []

touches: []

observables: []

with: []

morphClass: null

+exists: false +wasRecentlyCreated: false } `

is the word "slug" is prohibited or else? Please help me