me10071990
4 months ago

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

Posted 4 months ago by me10071990

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'=>"[email protected]",
'as'=>'Subcategories.store',

]);

route::get('/subcategory/edit/{id}',

[
    'uses'=>"[email protected]",

    'as'=>'Subcategories.edit',
]);

route::post('/subcategory/update/{id}',

[
    'uses'=>"[email protected]",

    '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 sign in or create an account to participate in this conversation.