im new to laravel, so i was following this guy tutorial https://www.youtube.com/watch?v=l6UlYfAsoR0&list=PLm8sgxwSZofdmlPxaDB7fRLv_NVe2uFKl&index=7 so i followed everything he did, but i ran into a problem where i was unable to redirect to the correct link, here is the code.
AdminController.php:
public function add_category(Request $request){
$category = new Category;
$category->category_name = $request->category;
$category->save();
return redirect()->back();
}
web.php:
Route::post('add_category', [AdminController::class,'add_category'])->
middleware(['auth', 'admin'])->name('admin.add_category')
category.blade.php:
<form action="{{url('add_category')}}" method="POST">
@csrf
<div>
<input type="text" name="category">
<input class="btn btn-primary" type="submit" value="Add Category">
</div>
</form>
for some reason when i clicked the add category btn, it sends me to the home page, please tell me what is wrong with it and if you guys have a better idea to work it please let me know, much thanks
Laravel E-Ccommerce Project Playlist : https://www.youtube.com/playlist?list=PLm8sgxwSZofdmlPxaDB7fRLv_NVe2uFKl
Get the E-Commerce Project Source Code : https://buymeacoffee.com/yaminshakil/e/265273
Join this channel to get access to perks:
https://www.youtube.com/channel/UCeNYDojo4nU2sbHz1sMsBXw/join
Thanks For Watching.
I hope This video ...