Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dpublic function post_details() {
- if (! \Request::is_hmvc()) {
- \Log::debug('No HMVC');
- $data['id'] = \Input::post('id', FALSE);
- } else {
- \Log::Debug('HMVC');
- $data['id'] = $this->param('id');
- }
- \Log::Debug('DCMS API - Book: ' . $data['id']);
- if ($data['id'] !== FALSE && $data['id'] !== NULL) {
- \Log::debug('Retrieving book details - ID' . $data['id']);
- $books = \Model_Book::query()->where('id', $data['id'])->get();
- $details = array();
- foreach ($books as $book) {
- $details['title'] = $book->name;
- $details['author'] = array();
- foreach ($book->authors as $a) {
- \Arr::insert($details['author'], $a->name,0);
- }
- }
- return $details;
- } else {
- \Log::Debug('Post was empty');
- $details['error'] = 'no_id_given';
- return $details;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement