forget() public method

Remove an item from the collection by key.
public forget ( string | array $keys )
$keys string | array
Example #1
0
 /**
  * @param WithInterface|DataInterface|ModelInterface $config
  * @return mixed
  */
 public function apply($config)
 {
     if (!($config instanceof WithInterface && $config instanceof DataInterface && $config instanceof ModelInterface)) {
         return;
     }
     if ($config->with()->isEmpty()) {
         return;
     }
     $this->config = $config;
     $this->allowed = $config->with();
     foreach ($this->allowed as $key => $value) {
         if (is_numeric($key)) {
             $this->allowed->forget($key)->put($value, '*');
         }
     }
     foreach (explode('|', $config->data()->get('with', '')) as $with) {
         $parts = explode(':', $with);
         if (count($parts) == 0) {
             continue;
         }
         if (!$this->allowed->has($parts[0])) {
             continue;
         }
         $this->processWith($parts[0], isset($parts[1]) ? $parts[1] : '');
     }
     if (count($this->approved) > 0) {
         $config->model($config->model()->with($this->approved));
     }
 }
 /**
  * Destroy a Satis repository.
  *
  * @param  \KevinDierkx\Muse\Repositories\Satis\RepositoryInterface  $model
  * @return \KevinDierkx\Muse\Repositories\Satis\RepositoryInterface
  */
 public function destroy(RepositoryInterface $model)
 {
     // TODO: Fire destroying event
     $this->repositories->forget($model->getId());
     $this->flush();
     // TODO: Fire destroyed event
     return $model;
 }
Example #3
0
 /**
  * @param $key
  * @param $amount
  * @param $item
  */
 protected function addExistsIntoItems($key, $amount, $item)
 {
     $temp = $this->_items->get($key);
     $temp['amount'] += $amount;
     $this->_items->forget($key);
     $this->_items->push($temp);
     $this->_totalPrice += $amount * $item->getPrice();
 }
 /**
  * @param string $type
  *
  * @return $this
  */
 public function removeMapping($type)
 {
     $this->mappings->forget($type);
     $mappings = $this->getMappingsForClass($type);
     foreach ($mappings as $key) {
         $this->mappings->forget($key);
     }
     return $this;
 }
 protected function isPublished(ServiceType $servicetype, Collection &$publishing)
 {
     foreach ($publishing as $key => $item) {
         if ($item['name'] == $servicetype->name) {
             $publishing->forget($key);
             return true;
         }
     }
     return false;
 }
Example #6
0
 /**
  * @param $key
  *
  * @return bool
  */
 public function forget($key)
 {
     if ($this->fireEvent('deleting', [$key]) === false) {
         return false;
     }
     $this->data->forget($key);
     $this->fireEvent('deleted', [$key], false);
     $this->dirty[] = $key;
     return true;
 }
 /**
  * Cleans the search results into authors with names that are
  * similar to the one that was searched.
  *
  * @param $query    String name of the author
  * @param $results  Collection containing the authors
  * @return mixed    Collection
  */
 protected function cleanSearch(string $query, Collection $results)
 {
     debug('Cleaning author search');
     foreach ($results as $author => $books) {
         // We only want to keep authors whose name is similar to our search query
         if ($this->authorsNameIsSimilar($query, $author)) {
             continue;
         }
         debug("Filtering {$author} from the results");
         $results->forget($author);
     }
     return $results;
 }
Example #8
0
 /**
  * agregar nuevo "otro" tratamiento al plan
  * @param int $indice
  * @param OtroTratamiento $tratamiento
  */
 public function agregarOtroTratamiento($indice, OtroTratamiento $tratamiento)
 {
     if (is_null($this->listaOtrosTratamientos)) {
         $this->listaOtrosTratamientos = new Collection();
     }
     /*if (count($this->listaTratamientos) === 2) {
           throw new \Exception('Solo se permiten hasta dos tratamientos por diente');
       }*/
     // si ya está ocupada la posición, la elimina para permitir agregar uno nuevo
     if ($this->listaOtrosTratamientos->has($indice)) {
         $this->listaOtrosTratamientos->forget($indice);
     }
     $this->listaOtrosTratamientos->put($indice, $tratamiento);
 }
Example #9
0
 /**
  * Deletes a row given a product id
  * @param $product_id
  * @throws Palmabit\Library\Exceptions\NotFoundException
  */
 public function deleteRowOrder($product_id)
 {
     $success = false;
     foreach ($this->row_orders as $key => $order) {
         if ($order->product_id == $product_id) {
             $this->row_orders->forget($key);
             $success = true;
         }
     }
     if (!$success) {
         throw new NotFoundException();
     }
     return $this;
 }
Example #10
0
 /**
  * Removes any empty groups from the compiled menu trees.
  *
  * @return $this
  */
 protected function filterEmptyGroups()
 {
     // Grouped
     $remove = [];
     foreach ($this->menuGroups as $key => $presence) {
         if (!$this->filterNestedEmptyGroups($presence)) {
             $remove[] = $key;
         }
     }
     $this->menuGroups->forget($remove);
     // Ungrouped
     $remove = [];
     foreach ($this->menuUngrouped as $key => $presence) {
         if (!$this->filterNestedEmptyGroups($presence)) {
             $remove[] = $key;
         }
     }
     $this->menuGroups->forget($remove);
     // Alternative presences should be left as is, to be determined
     // by whatever front-end implementation they may get.
     return $this;
 }
Example #11
0
 /**
  * Revoke role.
  *
  * @param string      $role_name
  * @param object|null $resource
  *
  * @return bool
  */
 public function revokeRole($role_name, $resource = null)
 {
     // Search Roles in Cache
     $delete_roles = $this->roles->filter(function ($role) use($role_name, $resource) {
         return $this->checkRole($role, $role_name, $resource);
     });
     if (!$delete_roles->count()) {
         return true;
     }
     $model_type = get_class($this->model);
     $model_id = $this->model->getKey();
     $delete = Role::where('model_type', $model_type)->where('model_id', $model_id)->where('role_name', $role_name);
     if (is_object($resource)) {
         $resource_type = get_class($resource);
         $resource_id = $resource->getKey();
         $delete->where('resource_type', $resource_type)->where('resource_id', $resource_id);
     }
     $delete->delete();
     foreach ($delete_roles->pluck('id') as $id) {
         $this->roles->forget($id);
     }
     return $delete;
 }
 /**
  * Removes criteria by key, if it exists
  *
  * @param string $key
  * @return $this
  */
 public function removeCriteria($key)
 {
     $this->criteria->forget($key);
     return $this;
 }
Example #13
0
 /**
  * @param Collection $inputs
  * @return mixed
  */
 private function getAuthData($inputs)
 {
     $auth_data = $inputs->get('authData');
     $inputs->forget('authData');
     return $auth_data;
 }
Example #14
0
 public static function buildQuickPassageStats($games)
 {
     $combined = [];
     $combined['stats'] = ['pandaPts' => 0, 'opponentPts' => 0, 'pandaWins' => 0, 'opponentWins' => 0, 'totalGames' => 0, 'blowoutGames' => 0, 'differentMaps' => false];
     $combined['buffs'] = ['favor' => false, 'mercy' => false, 'boon' => false, 'boon-or-favor' => false, 'quitout' => 0];
     $previous = null;
     $maps = new Collection();
     foreach ($games as $game) {
         $pandaId = $game->pvp->pandaId;
         $opponentId = $game->pvp->opposite($pandaId);
         if ($maps->has($game->referenceId)) {
             $count = $maps->get($game->referenceId);
             $maps->forget($game->referenceId);
             $maps->put($game->referenceId, ++$count);
         } else {
             $maps->put($game->referenceId, 1);
         }
         $combined['stats']['pandaPts'] += $game->pvp->pts($pandaId);
         $combined['stats']['opponentPts'] += $game->pvp->pts($opponentId);
         $combined['stats']['pandaWins'] += $pandaId == $game->pvp->winnerId ? 1 : 0;
         $combined['stats']['opponentWins'] += $opponentId == $game->pvp->winnerId ? 1 : 0;
         $combined['stats']['totalGames'] += 1;
         // Check if PandaLove blew them out (15 - 0)
         // Update: Trials #2 maxes at 5-0
         // Update: Forget max, just check if enemy got 0pts
         if ($pandaId == $game->pvp->winnerId) {
             if ($game->pvp->pts($opponentId) == 0) {
                 $combined['stats']['blowoutGames'] += 1;
             }
         }
         if ($previous == null) {
             $previous = $game->referenceId;
         } else {
             if ($previous != $game->referenceId) {
                 $combined['stats']['differentMaps'] = true;
             }
         }
         foreach ($game->players as $player) {
             $id = $player->account->membershipId;
             if ($player->account->isPandaLove() || $player->team == $pandaId) {
                 // check for unbroken
                 if ($player->deaths == 0) {
                     if (isset($combined['stats']['unbroken'][$id])) {
                         $combined['stats']['unbroken'][$id]['count'] += 1;
                     } else {
                         $combined['stats']['unbroken'][$id] = ['gamertag' => $player->account->gamertag, 'seo' => $player->account->seo, 'count' => 1];
                     }
                 }
             }
         }
     }
     // are we on different maps? If so lets get the names of them
     if ($combined['stats']['differentMaps']) {
         $map_list = '';
         $new_maps = null;
         $maps->each(function ($count, $map) use(&$map_list, &$new_maps) {
             $map_list .= Hashes::quick($map)['title'] . ", ";
         });
         $combined['stats']['maps'] = rtrim($map_list, ", ");
         $new_maps = $maps->toArray();
         arsort($new_maps);
         $combined['stats']['rMaps'] = $new_maps;
     }
     $bonus = 0;
     if ($combined['stats']['pandaWins'] < 7) {
         $combined['buffs']['quitout'] = 7 - $combined['stats']['pandaWins'];
         $bonus += $combined['buffs']['quitout'];
     }
     // Lets check for Boon/Mercy/Favor of Osiris
     if ($combined['stats']['pandaWins'] != $combined['stats']['totalGames']) {
         // Our Panda # of wins does not equal total games, therefore a loss was encountered
         $combined['buffs']['mercy'] = true;
     }
     if ($combined['stats']['pandaWins'] == 8 - $bonus) {
         // We have 8 wins. This means the group could of either used a Boon (First win = two wins)
         // or a Favor (start with 1 win).
         $combined['buffs']['boon-or-favor'] = true;
     }
     if ($combined['stats']['pandaWins'] == 7 - $bonus) {
         // We have 7 wins. That means both the Boon and Favor was used.
         $combined['buffs']['favor'] = true;
         $combined['buffs']['boon'] = true;
     }
     return $combined;
 }
Example #15
0
 /**
  * remover evaluacion
  * @param int $id
  */
 public function quitarEvaluacion($id)
 {
     $this->listaEvaluaciones->forget($id);
 }
Example #16
0
 /**
  * Generate Form Tag
  *
  * @param $attributes
  * @param Collection $attributes
  * @return string
  */
 protected function generateTag(Collection $attributes = null)
 {
     /**
      * Process Append Class
      */
     if ($appendClass = $attributes->pull('appendClass', null)) {
         $attributes->put('class', $attributes->get('class') . ' ' . $appendClass);
     }
     /**
      * Process Label
      */
     if ($label = $attributes->pull('label', null)) {
         $label = $this->makeLabel($this->trans($label));
     }
     /**
      * Process Errors
      */
     $error = $attributes->pull('error', null);
     $params = $this->collection->make();
     /**
      * Remove Element from attributes list
      * Define Attribute to be send for each kind of tag
      */
     switch ($tag = $attributes->pull('element')) {
         case 'hidden':
             $params->push([$attributes]);
             break;
         case 'select':
             $params->push([$attributes->forget('type'), $attributes->pull('collection'), $attributes->pull('placeholder'), $label]);
             break;
         case 'button':
             $params->push([$attributes, $attributes->pull('content')]);
             break;
         case 'errorMessage':
             $params->push([$attributes, $attributes->pull('errors'), $attributes->pull('title')]);
             break;
         default:
             $params->push([$attributes, $label, $error]);
             break;
     }
     /**
      * Call function with params
      */
     return call_user_func_array(array($this, 'make' . title_case($tag)), $params->collapse()->toArray());
 }
 /**
  * Removes postProcessor
  *
  * @param $class
  * @return $this
  */
 public function removePostProcessor($class)
 {
     $this->postProcessors->forget($class);
     return $this;
 }
Example #18
0
 public function testForgetArrayOfKeys()
 {
     $c = new Collection(['foo', 'bar', 'baz']);
     $c->forget([0, 2]);
     $this->assertFalse(isset($c[0]));
     $this->assertFalse(isset($c[2]));
     $this->assertTrue(isset($c[1]));
     $c = new Collection(['name' => 'taylor', 'foo' => 'bar', 'baz' => 'qux']);
     $c->forget(['foo', 'baz']);
     $this->assertFalse(isset($c['foo']));
     $this->assertFalse(isset($c['baz']));
     $this->assertTrue(isset($c['name']));
 }
Example #19
0
 /**
  * Removes a menu
  *
  * @param $id
  *
  * @return MenuFactory
  */
 public function forget($id)
 {
     $this->runHook('menu-factory:forget', [$this, $id]);
     $this->menus->forget($id);
     return $this;
 }
 /**
  * @param $level
  * @return $this
  */
 private function extend($level)
 {
     $this->extended->forget(0);
     $this->extended->push($level);
     return $this;
 }
Example #21
0
 /**
  * @param $mode
  * @param Collection|Attribute[] $attributes
  * @param $model
  *
  * @return mixed
  */
 public function setAttributeValues($mode, Collection $attributes, Model $model)
 {
     foreach ($attributes as $key => $attr) {
         if ($mode === 'create' && $attr->hasFlag('hide_add')) {
             $attributes->forget($key);
         }
         if ($mode === 'edit') {
             if ($attr->hasFlag('hide_edit')) {
                 $attributes->forget($key);
             }
             $model->{$attr->name} = $attr->getEditValue($model);
         }
     }
     return $attributes;
 }
 /**
  * Unset the item at the given key.
  *
  * @param  mixed  $key
  * @return void
  */
 public function offsetUnset($key)
 {
     $this->items->forget($key);
 }
 public function updateJudges(FormDefinition $form, Request $request)
 {
     $this->validate($request, ['judges' => 'required|array', 'judges.*' => 'exists:users,id']);
     $error_list = new Collection();
     $updated_judges = new Collection();
     foreach ($request->input('judges') as $new_judge_id) {
         try {
             $judge = $form->group()->first()->adjudicatorUsers()->findOrFail($new_judge_id);
             $updated_judges->put($judge->id, $judge);
         } catch (\Exception $e) {
             $error_list->push("Judge with User ID of " . $new_judge_id . " not found and thus not added!");
         }
     }
     $current_judges = $form->judges()->get();
     foreach ($current_judges as $cur_judge) {
         if (!$updated_judges->has($cur_judge->id)) {
             $form->judges()->detach($cur_judge->id);
         }
         $updated_judges->forget($cur_judge->id);
     }
     foreach ($updated_judges as $new_judge) {
         $form->judges()->save($new_judge);
     }
     if ($error_list->count() > 0) {
         $error_string = "";
         foreach ($error_list as $error) {
             $error_string = $error_string . "<br>{$error}";
         }
         flash()->overlay("Something went wrong, and not all the judges may have been added correctly.  Double check the results." . $error_string, "Error");
         return redirect()->back();
     } else {
         flash()->overlay("The judges have been added to the form", "Form Updated");
         return redirect()->back();
     }
 }