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);
 }
示例#2
0
 /**
  * Deletes a type
  *
  * @param $type
  * @return null
  */
 public function delete($type)
 {
     if (is_int($type) && TypeModel::find($type)) {
         return TypeModel::find($type)->delete();
     }
     if ($type instanceof TypeModel) {
         return $type->delete();
     }
     if (TypeModel::whereName($type)->first()) {
         return TypeModel::whereName($type)->first()->delete();
     }
 }
示例#3
0
 public function test_it_deletes_a_type_from_name_argument()
 {
     $type_to_deleted = TypeModel::find(1);
     (new Type())->delete($type_to_deleted->name);
     $this->assertNull(TypeModel::find(1));
 }
示例#4
0
 /**
  * Check if type with id $id exists
  *
  * @param $id
  * @return bool
  */
 public function typeExists($id)
 {
     return is_null(TypeModel::find($id)) ? false : true;
 }