1pppp

Untitled

Aug 18th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1.  
  2. public function edit($id, Category $category)
  3. {
  4. $product = Product::where('id',$id)->first();
  5. $categories = Category::whereNull('category_id')->with('childrenCategories')->get();
  6. return view('product.edit', compact('categories','product'));
  7.  
  8. }
  9.  
  10.  
  11. ErrorException
  12. Undefined variable: category (View: /var/www/bossphp.x/resources/views/product/edit.blade.php)
  13. http://bossphp.x:8080/product/edit/38
  14.  
  15.  
  16. <div class="form-group">
  17. <label>Подкатегории</label>
  18. <select class="form-control input-sm" name="category_id">
  19. <!-- --><?php //dd($categories); ?>
  20. <option selected value="{{$product->category_id}}">--select--</option>
  21. @foreach ($categories as $firstcategory)
  22. <option @if($firstcategory->id == $category->category_id) selected @endif value="{{$firstcategory->id}}">{{$firstcategory->title}}</option>
  23.  
  24. @if($firstcategory->categories)
  25. @foreach ($firstcategory->categories as $subcategory)
  26. <option @if($subcategory->id == $category->category_id) selected @endif value="{{$subcategory->id}}">-----{{$subcategory->title}}</option>
  27. @endforeach
  28. @endif
  29. @endforeach
  30. </select>
  31. </div>
Add Comment
Please, Sign In to add comment