9 months ago

Adding new method to controller

Posted 9 months ago by boby

Hi all. This is my first post on this forum, and I am very new to laravel. What I am trying to do is this:

I am building something like books library. I have created BookController which has standard methods as: create, update, destroy, etc... and in web.php there is "Route::resource('books', 'BooksController');"

Now when I am on specific book page, I am listing my users from DB to whom I want to rent this book. I have form on this page, but I don't know where I should point it, maybe, action=/book/{$book-id}/rent? Then I would need rent page, which I don't want. I want to do a insert query user_id & book_id pair to DB, and go back to start page /books.

Can I add rent method to BookController and how to point to it from rent form? How to send book_id and user_id which I have on that page where form is?

Sorry for such long post.

Thanks, Slobodan

Please sign in or create an account to participate in this conversation.