/** * show the previous or NEXT item in the list of items related to a plan * or swap between chords and sheetmusic * * @param int $id plan id * @param int $id item id or: 'seq-no-<seq_no>' ! * @param string $direction next|previous|swap * @param string $chords (chords|sheetmusic) * * @return \Illuminate\Http\Response */ public function next(Request $request, $plan_id, $item_id, $direction, $chords = null) { // get item id of next or previous item from helper function $new_item_id = nextItem($plan_id, $item_id, $direction); // call edit with new item id if ($chords == null) { return $this->edit($plan_id, $new_item_id); } // swap between showing chords or sheetmusic if ($direction == 'swap') { if ($chords == 'chords') { $chords = 'sheetmusic'; } else { $chords = 'chords'; } } if ($chords == 'chords') { return $this->show($new_item_id); } return $this->show($new_item_id, $chords); }
function getItemTitle($item, $direction = 'next') { $nextItemId = nextItem($item->plan_id, $item->id, $direction); $item = Item::find($nextItemId); if ($item->song_id && $item->song->title) { return $item->song->title; } return $item->comment; }