<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\prod_cat;
use App\product;
use App\category;
class ProdCatController extends ProductController
{
public function store1(Request $req)
{
//dd($req->all());
prod_cat::create([
'p_id'=>request('p_id'),
'c_id'=>request('c_id'),
]);
$product=product::get();
$category=category::get();
$prod_cat=prod_cat::get();
return redirect('pcview');
}
public function show1()
{
$product=product::get();
$category=category::get();
$prod_cat=prod_cat::get();
return view('pcview',compact('product','category','prod_cat'));
//return redirect('prodview');
}
}
Use name="c_id[]" to store the checkmarks in an array when sent to the controller.
If they need to be in one field/row in the database, you could json encode the checkboxes and decode them when retrieved. Alternatively you can have a row for each product/category relation