fsdolphin's avatar

Understanding Route::post

Hi,

I have bee watching the Laravel 5 Fundamentals and I'm not sure what does 'articles' do in the following post route...

Route:post('articles', 'ArticlesController@store');

Is 'articles' referring to the table's name from the database?

Thanks

0 likes
6 replies
davorminchorov's avatar
Level 53

articles refers to the URL /articles. When someone sends a post request (usually that happens through a form) to that route, the store() method will be called on the ArticlesController

1 like
fsdolphin's avatar

I got it now. I was confused because I didn't see where or how this was used, I was looking for a view with that name, but now I see that articles refers to a folder with an index.php view inside which retrieves the information.

Make totally sense.

SachinAgarwal's avatar

@fsdolphin "articles" do not refer to folder. Its nothing but you URI i.e., :

Route::get('articles','ArticlesController@create');
//Above route will allow you to access the url address like this: "{website}/articles" with a GET REQUEST
// That's it and it points nothing else.
 Route::post('articles', 'ArticlesController@store');
// This will also refer to "{website}/articles" but this time with a POST REQUEST

If you do not know the difference between "Post" and "Get" requests Then read this : http://www.w3schools.com/tags/ref_httpmethods.asp

1 like
fsdolphin's avatar

@SachinAgarwal "articles" do not refer to folder. Its nothing but you URI i.e., :

I said it refers to a folder because articles is the directory or URL where post is pointing to and in a sense it is a folder. Sorry if my assumption is not even close.

Please or to participate in this conversation.