Laravel difference between resource.create and resource.store

13,950

Solution 1

just a simple example. (oversimplification)

let's say you are writing a blog.

the GET request you are sending to get the form (where you will write the blog) is resource.create.

after finishing the writing, when you will submit and POST the content so that it gets saved in somewhere, it is resource.store

in your case,

registration form is resource.create.

saving the info (submitting the form) is resource.store.

Solution 2

resource.create shows the form for creating a new resource (front end only to show the form) and resource.store stores a newly created resource in storage (db interaction to store the data).

Solution 3

resource.create = Frontend

resource.store = Backend

Share:
13,950

Related videos on Youtube

user2722667
Author by

user2722667

Updated on June 15, 2022

Comments

  • user2722667
    user2722667 almost 2 years

    I am about to learn about building RestFul apps in Laravel but I dont understand the difference between resource.create and resource.store

    If I want to register and create a new user, does it then use resource.create or resource.store ?

    If not, when to use resource.create ? And when should I use resource.store ?

    Cheers,

  • user2722667
    user2722667 over 9 years
    Super simple, thanks! Then I am only going with store() since im hooking my api up to an iOS app.
  • plushyObject
    plushyObject about 8 years
    Thanks this is strangely vauge in the documentation
  • ankush981
    ankush981 about 7 years
    @plushyObject Very, very vague, and not needed in most cases. It just makes everything so confusing.
  • Cr1xus
    Cr1xus over 5 years
    I don't get it.. why would you need a create() function in backend for the form when you have <form> in front end? can you give me an example when you would want to prepare the form?
  • itachi
    itachi over 5 years
    The create function displays the form. Not the other way around by convention.
  • Admin
    Admin over 2 years
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.