/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $species = Species::find($id); if ($species) { try { // Delete breed, if not possible, catch error. $species->delete(); } catch (Exception $e) { // If breed to be deleted is in use, send nice error back to admin. return Redirect::back()->with('message', FlashMessage::DisplayAlert('Species can NOT be deleted because it\'s in use.', 'alert')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Species Deleted Successfully!', 'success')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Record Not Found.', 'alert')); }
function test_find() { //Arrange $name = "naked mole rat"; $fur = 0; $wings = 0; $legs = 4; $test_species = new Species($name, $fur, $wings, $legs); $test_species->save(); //Act $result = Species::find("naked mole rat"); //Assert $this->assertEquals($test_species, $result); }