ProductCntrl.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Product;
  4. use Illuminate\Http\Request;
  5. class ProductCntrl extends Controller
  6. {
  7. /**
  8. * Display a listing of the resource.
  9. *
  10. * @return \Illuminate\Http\Response
  11. */
  12. public function index()
  13. {
  14. $products =new Product;
  15. $category = new Category;
  16. $category->id = 1;
  17. $products->id = 1;
  18. $products->categories()->attach([$category->id,$products->id]);
  19. $prd = Product::with('categories')->get();
  20. return view('home',['products'=>$prd]);
  21. }
  22. /**
  23. * Show the form for creating a new resource.
  24. *
  25. * @return \Illuminate\Http\Response
  26. */
  27. public function create()
  28. {
  29. //
  30. }
  31. /**
  32. * Store a newly created resource in storage.
  33. *
  34. * @param \Illuminate\Http\Request $request
  35. * @return \Illuminate\Http\Response
  36. */
  37. public function store(Request $request)
  38. {
  39. //
  40. }
  41. /**
  42. * Display the specified resource.
  43. *
  44. * @param int $id
  45. * @return \Illuminate\Http\Response
  46. */
  47. public function show($id)
  48. {
  49. //
  50. }
  51. /**
  52. * Show the form for editing the specified resource.
  53. *
  54. * @param int $id
  55. * @return \Illuminate\Http\Response
  56. */
  57. public function edit($id)
  58. {
  59. //
  60. }
  61. /**
  62. * Update the specified resource in storage.
  63. *
  64. * @param \Illuminate\Http\Request $request
  65. * @param int $id
  66. * @return \Illuminate\Http\Response
  67. */
  68. public function update(Request $request, $id)
  69. {
  70. //
  71. }
  72. /**
  73. * Remove the specified resource from storage.
  74. *
  75. * @param int $id
  76. * @return \Illuminate\Http\Response
  77. */
  78. public function destroy($id)
  79. {
  80. //
  81. }
  82. }