Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-CRUD Controller Actions

This might seem like a n00b question, but I am trying to break some of my bad practice that I may have adopted using MVC, so I hope you can help me out

So, imagine I want to do something like "Upload CSV And Parse It", it doesn't seem obvious to me to fit it into the CRUD pattern... I am not interacting with the DB, so i don't need add or update or delete, but I still want to be able to use the action in a meaningful way from different views. Thus, it is "ok" to just an action called "UploadCSV" and have it be accessible via a URL such as "/data/uploadcsv"

Your thoughts are much appreciated!

Tom

like image 920
thoswarner Avatar asked Nov 14 '22 14:11

thoswarner


1 Answers

It sounds like you are talking about RESTful ideas (having actions called index, create, new, edit, update, destroy, show).

In MVC you can call an action largely whatever you want (so yes, you can call it uploadcsv if you want). If you want it fit RESTful principles you might want to think about what the action is doing (for example is a data upload essentially a create or an update function) and name it using one of the RESTful action names.

like image 150
Michael Gattuso Avatar answered Nov 24 '22 01:11

Michael Gattuso