My situation is that when I, for example, create a post or add data in the database. I have the following challenge.
I have the following route and controller.
Route::resource('books', 'BooksController')
I want to use /books/create (This returns an error to say "Page you are looking for could not be found"
It work when I use
Route::match(['get','post'],'/admin/add-book','BooksController@addBook');
{{ url('/admin/add-book')}}
I want to use the former (This: book/create or books.create) but I don't get the view or page.
<a href="{{ route('books.create')}}">Add Ebooks ( I want this but it says the page is not found) Route::resource('books', 'BooksController')
public function create() {
return view('books.create', compact('category'));
}
I PREFERE THE ABOVE METHOD THAN THE BELOW. Which says the page is not found
<a href="{{ url('/admin/add-book')}}">Add Ebook (This works well but i loose the books.store method)
Route::match(['get','post'],'/admin/add-book','BooksController@addBook');
public function addBook(Request $request){
return view('admin.books.add_book')->with(compact('categories_drop_down'));
In my resources/view - i have admin/book/ and create, index, show blades, and also add_book.blade.php
Thank you, please understand that I Am trying to understand the difference between the two. Just because i have two routes does not mean I use them both.
// Admin Ebook Routes
Route::resource('books', 'BooksController'); ------- (I PREFRE TO USE THIS SINCE IT GIVE ME ADVANTAGE OF THE STORE METHOD WHEN I CREATE BOOK BUT IT SEEMS NOT TO WORK)
Route::match(['get','post'],'/admin/add-book','BooksController@addBook');
Route::match(['get','post'],'/admin/edit-book/{id}','BooksController@editBook');
Route::get('/admin/delete-book/{id}','BooksController@deleteBook');
Route::get('/admin/view-books','BooksController@viewBooks');
Route::get('/admin/delete-book-image/{id}','BooksController@deleteBookImage');