Closed yukopangestu closed 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
0 => "id" 1 => "parent_id" 2 => "lft" 3 => "rgt" 4 => "depth" 5 => "slug"
]
+incrementing: true +timestamps: true
"name" => "nose" "description" => "nose"
+exists: false +wasRecentlyCreated: false } `
is the word "slug" is prohibited or else? Please help me
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') ]); }
`
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 [
]
orderColumn: null
scoped: []
connection: null
primaryKey: "id"
perPage: 15
+incrementing: true +timestamps: true
attributes: array:2 [
]
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