예제 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $category = new Categories();
     $category->name = $request->input('name');
     $category->parent_id = $request->input('parent_id');
     if ($category->parent_id != 0) {
         $cat = Categories::FindOrFail($category->parent_id);
         $category->level = $cat->level + 1;
         DB::table('categories')->where('id', '=', $id)->update(['name' => $category->name, 'parent_id' => $category->parent_id, 'level' => $category->level]);
     } else {
         dd();
     }
 }