how can i get the subcategory list while clicking in the category list
here is my route
Route::resource('admindashboard/subcategory','Admin\SubCategory\SubCategoryController');
Route::resource('admindashboard/category','Admin\Category\CategoryController');
Route::resource('admindashboard/products','Admin\Products\ProductController');
here is my blade file
<div class="col-lg-4">
<div class="form-group mg-b-10-force">
<label class="form-control-label">Category: <span class="tx-danger">*</span></label>
<select class="form-control select2" name="category_id" data-placeholder="Choose Category">
<option label="Choose Category">Choose Category</option>
@foreach ($categories as $category)
<option value="{{ $category->id }}">{{$category->name }}</option>
@endforeach
</select>
</div>
</div><!-- col-4 -->
<div class="col-lg-4">
<div class="form-group mg-b-10-force">
<label class="form-control-label">Sub Category: <span class="tx-danger">*</span></label>
<select class="form-control select2" name="subcategory_id" data-placeholder="Choose Sub Category">
//get list of sub categories while selecting category
</select>
</div>
</div><!-- col-4 -->
here is my product controller
public function index()
{
return view('admin.products.index');
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('admin.products.add')->with('categories',Category::all())->with('brands',Brand::all());
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
field name in categories and subcategories are
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->timestamps();
});
}
public function up()
{
Schema::create('sub_categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->integer('category_id');
$table->timestamps();
});
}
i think this can be done through ajax but i dont know help me with code