Could you please fix the formatting of your code? Half of it is outside code blocks.
I am able to add the value in both (cat and subcat) but on my website only menu showing how can make submenu of menu
I made a menu dynamically and trying to make sub-menu but getting nothing happend
here is Category model
public function subCategory() { return $this->hasMany('App\Category','sub_cat_id');
}
public function Category() { return $this->belongsTo('App\Category','sub_cat_id'); } class Subcategory extends Model { protected $fillable = ['id', 'sub_cat_id', 'sub_cat_name'];
public function category()
{ return $this->belongsTo('App\Category'); } } and route is
route::post('/Subcategory/store',[
'uses'=>"subCategoriesController@store",
'as'=>'Subcategories.store',
]);
route::get('/subcategory/edit/{id}',
[
'uses'=>"subCategoriesController@edit",
'as'=>'Subcategories.edit',
]);
route::post('/subcategory/update/{id}',
[
'uses'=>"subCategoriesController@update",
'as'=>'Subcategories.update',
]);
And Controller for Subcateogry is public function store(Request $request) { $this->validate($request, [
'sub_cat_name' =>'required',
'sub_cat_id' => 'required'
]);
$data=[
'sub_cat_id'=>$request->sub_cat_id,
'sub_cat_name'=>$request->sub_cat_name,
];
$subcategory=Subcategory::create($data);
Session::flash('success', 'Subcategory has created successfully');
return redirect()->back();
} and Controller for Category
public function store(Request $request) {
$this->validate($request, [
'name' =>'required'
]);
$category= new Category;
$category->name =$request->name;
$category->save();
Session::flash('success', 'Category has created successfully');
return redirect()->back();
}
and only I am able to add the value in both (cat and subcat) but on my website only menu showing how can make submenu of menu
Please or to participate in this conversation.