/** * Convert the keys of an array which are flashcard ids to actual flashcard objects. */ private function convertArrayKeysToFlashcards(array $array) { $flashcards = []; foreach ($array as $key => $value) { $flashcards[] = \App\Flashcard::find((int) $key); } return $flashcards; }
public function editCard(Request $request) { $flashcardId = $request->flashcard_id; $flashcard = Flashcard::find($flashcardId); $flashcard->update(['front' => $request->front, 'back' => $request->back]); }