public function delete($id) { $activity = TypeModel::find($id); if (!$activity) { return response()->json(['message' => 'Activity with given id not found'], 404); } $activity->delete(); return response()->json(['message' => 'Activity deleted'], 200); }
/** * Truncates Table * * @return boolean */ public function truncate() { DB::transaction(function () { TypeModel::truncate(); }); }
public function test_it_empty_the_types_table() { (new Type())->truncate(); $this->assertEquals(0, TypeModel::count()); }
/** * Check if type with id $id exists * * @param $id * @return bool */ public function typeExists($id) { return is_null(TypeModel::find($id)) ? false : true; }