This may be a silly question, but I haven't find any way to solve it yet. My project mate wrote server side of our project using Laravel. My job is to develop Android App. I know how to send and receive JSON between Android and PHP. However, I don't know much about Laravel. So I don't know which URL should I use to send/receive JSON.
To which URL should I send my JSON to use the following post_list() method under the file my_application_name/application/controllers/menucategory.php ?
<?php
class MenuCategory_Controller extends Base_Controller {
public $restful = true;
public function post_list() {
$categories = MenuCategory::all();
$cat = null;
foreach ($categories as $category) {
$cat[] = array(
'id' => $category->id,
'name' => $category->name
);
}
return Response::json(array('categories' => $cat));
}
}
?>
Since the controller is restful, you just need to point to the name of the controller, and the name of the method (without the action)
e.g., in this case, you
post
tomenucategory/list
since it's the MenuCategory controller, and youpost
tolist
More information on this can be seen in the laravel docs here: http://laravel.com/docs/controllers#restful-controllers