0

I'm developing a RESTful API with Laravel 4 in which I want to upload pictures related to users (profile pics or galleries). I want to keep it as REST orthodox as I can. How should I treat the pictures? as a separate resource (relation)? And what would be the best way to map them in my URLs and actions?

Thanks!!

Pablo.mtz
  • 152
  • 3
  • 11

2 Answers2

0

If you want to use one controller across the whole application dedicated to uploading files you can treat that as a resource.

The resource supported actions in Laravel are the folling:

http://paste.laravel.com/Qs6

If you instead want to add an additional action and URL besides the default, you can achieve that by doing this:

https://stackoverflow.com/a/16661375/385402

Community
  • 1
  • 1
Glad To Help
  • 5,299
  • 4
  • 38
  • 56
  • Using Laravel's supported actions, how would I be able to make the relation between the file and the user? And if I declare a new action, how could I make the relation while still respecting REST? @glad-to-help – Pablo.mtz Sep 18 '13 at 01:31
  • I am not sure which aspect of REST would be violated. Could you please specify? – Glad To Help Sep 18 '13 at 02:00
0

The best option I found was using Laravel's nested resources. Here's a quick and effective tut by Jeffrey Way on how to achieve this. http://tutsplus.com/lesson/nested-resources

Pablo.mtz
  • 152
  • 3
  • 11