public function addNew($requestData)
 {
     $dragon = new Dragon();
     // Add a new level up
     $levelUp = new LevelUp();
     $levelUp->save();
     $dragon->levelUp()->associate($levelUp);
     $this->setData($dragon, $requestData);
     return $dragon;
 }
 public function merge($ids)
 {
     // get the first sequence
     $firstID = array_pop($ids);
     $sequence = LevelUp::find($firstID);
     // Check the sequences are the same
     foreach ($ids as $id) {
         $oldSeq = LevelUp::find($id);
         foreach ($oldSeq->data as $data) {
             $newData = $sequence->data->where('level', $data->level)->first();
             if ($newData) {
                 if ($newData->fish !== $data->fish || $newData->wood !== $data->wood || $newData->iron !== $data->iron || $newData->time !== $data->time) {
                     \Notification::add('warning', 'Sequences are different at level ' . $newData->level . '!');
                     return false;
                 }
             }
         }
     }
     foreach ($ids as $id) {
         // then reattach the other dragons to this sequence
         foreach ($oldSeq->dragons as $dragon) {
             $dragon->levelUp()->associate($sequence);
             $dragon->save();
         }
         // Copy data across or delete the data
         foreach ($oldSeq->data as $data) {
             $newData = $sequence->data->where('level', $data->level)->first();
             if (!$newData) {
                 $sequence->data()->save($data);
             } else {
                 $data->delete();
             }
         }
         // and delete the sequence
         $oldSeq->delete();
     }
 }