push() public method

Push an item onto the end of the collection.
public push ( mixed $value )
$value mixed
Example #1
0
 /**
  * Register the location.
  *
  * @return void
  */
 public function register()
 {
     if (empty($this->migrate)) {
         return false;
     }
     $this->locations->push([$this->migrate, $this->using ?: null]);
 }
Example #2
0
 /**
  * Adds a row to his collection
  * @param Product $product
  * @param         $quantity
  * @param Palmabit\Catalog\Models\RowOder
  */
 public function addRow(Product $product, $quantity, RowOrder $row_order = null)
 {
     $row = $row_order ? $row_order : new RowOrder();
     $quantity = $this->clearDuplicatesAndUpdateQuantity($product, $quantity);
     $row->setItem($product, $quantity);
     $this->row_orders->push($row);
 }
Example #3
0
 /**
  * @param CategoryModel $category
  */
 public function addCategory(CategoryModel $category)
 {
     // spent is minus zero for an expense report:
     if ($category->spent < 0) {
         $this->categories->push($category);
     }
 }
 public function auxiliarLibros($cuenta_bancaria_id, $aaaa, $mm)
 {
     $fecha = FechasUtility::fechasConciliacion($aaaa, $mm);
     $this->fecha_inicio = $fecha['inicial'];
     $this->fecha_fin = $fecha['final'];
     $this->cuenta_bancaria_id = $cuenta_bancaria_id;
     $auxiliar_registros = new Collection();
     $ingresos = $this->getIngresos();
     $ingresos->each(function ($item) use($auxiliar_registros) {
         $auxiliar_registros->push($item);
     });
     $egresos = $this->getEgresos();
     $egresos->each(function ($item) use($auxiliar_registros) {
         $auxiliar_registros->push($item);
     });
     /**
      * @todo Consultar Pólizas de Ingresos (Pendiente hasta agregar cuenta_bancaria_id en tabla polizas)
      */
     //        $polizas_ingreso = $this->getPolizasIngresos();
     //        $auxiliar_registros->push($polizas_ingreso->map(function ($item){
     //            return $item;
     //        }));
     $canacelados = $this->getCancelados();
     $canacelados->map(function ($item) use($auxiliar_registros) {
         $auxiliar_registros->push($item);
     });
     //Ordenar por fecha, poliza, cheque
     $auxiliar_registros = $auxiliar_registros->sortBy(function ($aux) {
         return sprintf('%-12s %s %s', $aux->fecha, $aux->poliza, $aux->cheque);
     });
     return view('conciliacion.auxiliarLibros', compact('auxiliar_registros'));
 }
Example #5
0
 public function getTest()
 {
     $numberInitial = 200;
     $numberMarried = floor($numberInitial * 10 / 100);
     $genders = [Personnage::GENDER_FEMALE, Personnage::GENDER_MALE];
     $chars = new Collection();
     for ($i = 0; $i < $numberInitial; $i++) {
         $char = new Personnage();
         $chars->push($char);
         $char->setGender($genders[array_rand($genders)]);
         $char->setAge(random_int(1, 60));
         $char->setName($i);
     }
     //Create some marriages
     foreach ($chars as $char) {
         if ($char->age > 15) {
             $numberMarried--;
             $spouse = new Personnage();
             $spouse->setAge(max(15, random_int($char->age - 5, $char->age + 5)));
             $spouse->setGender($char->gender == Personnage::GENDER_MALE ? Personnage::GENDER_FEMALE : Personnage::GENDER_MALE);
             $spouse->setName("Spouse {$numberMarried}");
             $relation = new MarriedTo($spouse, $char);
             $spouse->addRelation($relation);
             $chars->push($spouse);
             //Get them some babies!
             $totalBabies = random_int(0, min(abs($char->age - $spouse->age), 5));
             $siblings = [];
             for ($i = 0; $i < $totalBabies; $i++) {
                 $child = new Personnage();
                 $child->setGender($genders[array_rand($genders)]);
                 $child->setName("Child {$numberMarried}.{$i}");
                 $relation1 = new ParentOf($char, $child);
                 $relation2 = new ParentOf($spouse, $child);
                 $char->addRelation($relation1);
                 $spouse->addRelation($relation2);
                 $chars->push($child);
                 foreach ($siblings as $sibling) {
                     $relation = new SiblingOf($sibling, $child);
                     $sibling->addRelation($relation);
                 }
                 $siblings[] = $child;
             }
         }
         if ($numberMarried <= 0) {
             break;
         }
     }
     /*$man1 = new Personnage();
             $woman1 = new Personnage();
     
             $man1->setName('man1');
             $woman1->setName('woman1');
     
             $man1->setAge(random_int(20, 50));
             $woman1->setAge(max(15,random_int($man1->age - 5, $man1->age + 5)));
     
             $married = new MarriedTo($man1, $woman1);
             $man1->addRelation($married);*/
     echo implode('<br/>', $chars->toArray());
 }
Example #6
0
 function getTotalUpcomingSchedulesAttribute()
 {
     if (!isset($this->total_upcoming_schedules)) {
         $destination_ids = new Collection();
         $destination_ids->push($this->id);
         foreach ($this->descendant as $x) {
             $destination_ids->push($x->id);
         }
         $this->total_upcoming_schedules = TourSchedule::whereHas('tour', function ($query) use($destination_ids) {
             $query->InDestinationByIds($destination_ids);
         })->scheduledBetween(\Carbon\Carbon::now(), \Carbon\Carbon::now()->addYear(5))->count();
     }
     return $this->total_upcoming_schedules;
     // $destination_ids = Static::where(function($query) uses ($this) {
     // 	$query->where('id', '=', $this->id)
     // 			->orWhere($this->getPathField(), 'like', $this->attributes[$this->getPathField()] . Static::getDelimiter() . '%')
     // })->join('tours', 'tours.')
     // // calculate this destination total schedules
     // $total_schedule = 0;
     // foreach ($this->tours as $tour)
     // {
     // 	$total_schedule += $tour->schedules->count();
     // }
     // // calculate this destination and its children total schedules
     // $descendants = $this->descendant;
     // $descendants->load('tours', 'tours.schedules');
     // foreach ($descendants as $descendant)
     // {
     // 	foreach ($descendant->tours as $tour)
     // 	{
     // 		$total_schedule += $tour->schedules->count();
     // 	}
     // }
     // return $total_schedule;
 }
Example #7
0
 /**
  * Insert new permision
  * 
  * @param  array $item
  * @return array
  */
 public function insert(array $item)
 {
     if (!$this->find($item[$this->id])) {
         $this->items->push($item);
     }
     return $item;
 }
Example #8
0
 /**
  * @return Collection
  */
 public function generateMenu()
 {
     $menu = new Collection();
     if (!$this->auth->getUser()) {
         return $menu;
     }
     if (config('shapeshifter.menu')) {
         foreach (config('shapeshifter.menu') as $item) {
             $item = $this->parseItem($item);
             $menu->push($item);
         }
     } else {
         foreach ($this->modules->getOrdered() as $module) {
             $attributes = $module->json()->getAttributes();
             $item = $this->parseItem($attributes);
             $menu->push($item);
         }
     }
     return $menu->filter(function ($item) {
         return $this->hasAccessToRoute($item['route']);
     })->map(function ($item) {
         $item['children'] = array_filter($item['children'], function ($item) {
             return $this->hasAccessToRoute($item['route']);
         });
         return $item;
     })->filter(function ($item) {
         return $this->hasAccessToRoute('superuser') || count($item['children']) === 0 && $item['route'] !== null;
     });
 }
Example #9
0
 public function addItem(AbstractItem $item)
 {
     if (is_null($this->items)) {
         $this->items = new Collection();
     }
     $this->items->push($item);
 }
 public function addColumn($column)
 {
     if (NULL === $this->columns) {
         $this->columns = Collection::make([]);
     }
     $this->columns->push($column);
     return $this;
 }
 public function push(Event $event, array $customAttributes = [])
 {
     if (!empty($customAttributes)) {
         $this->events->push($this->convertToArray($event, $customAttributes));
     } else {
         $this->events->push($event);
     }
 }
Example #12
0
 public function add(array $message, $flash = true)
 {
     $this->messages->push($message);
     if ($flash) {
         $this->session->flash('__messages', $this->messages);
     }
     return $this;
 }
Example #13
0
 public function html($value = null)
 {
     if ($value == null) {
         return $this->buildChildren();
     }
     $value = value($value);
     $this->children = new Collection();
     $this->children->push($value);
 }
Example #14
0
 /**
  * Shows all bills and whether or not theyve been paid this month (pie chart).
  *
  * @param BillRepositoryInterface    $repository
  * @param AccountRepositoryInterface $accounts
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function frontpage(BillRepositoryInterface $repository, AccountRepositoryInterface $accounts)
 {
     $start = Session::get('start', Carbon::now()->startOfMonth());
     $end = Session::get('end', Carbon::now()->endOfMonth());
     // chart properties for cache:
     $cache = new CacheProperties();
     $cache->addProperty($start);
     $cache->addProperty($end);
     $cache->addProperty('bills');
     $cache->addProperty('frontpage');
     if ($cache->has()) {
         return Response::json($cache->get());
         // @codeCoverageIgnore
     }
     $bills = $repository->getActiveBills();
     $paid = new Collection();
     // journals.
     $unpaid = new Collection();
     // bills
     /** @var Bill $bill */
     foreach ($bills as $bill) {
         $ranges = $repository->getRanges($bill, $start, $end);
         foreach ($ranges as $range) {
             // paid a bill in this range?
             $journals = $repository->getJournalsInRange($bill, $range['start'], $range['end']);
             if ($journals->count() == 0) {
                 $unpaid->push([$bill, $range['start']]);
             } else {
                 $paid = $paid->merge($journals);
             }
         }
     }
     $creditCards = $accounts->getCreditCards();
     foreach ($creditCards as $creditCard) {
         $balance = Steam::balance($creditCard, $end, true);
         $date = new Carbon($creditCard->getMeta('ccMonthlyPaymentDate'));
         if ($balance < 0) {
             // unpaid! create a fake bill that matches the amount.
             $description = $creditCard->name;
             $amount = $balance * -1;
             $fakeBill = $repository->createFakeBill($description, $date, $amount);
             unset($description, $amount);
             $unpaid->push([$fakeBill, $date]);
         }
         if ($balance == 0) {
             // find transfer(s) TO the credit card which should account for
             // anything paid. If not, the CC is not yet used.
             $journals = $accounts->getTransfersInRange($creditCard, $start, $end);
             $paid = $paid->merge($journals);
         }
     }
     // build chart:
     $data = $this->generator->frontpage($paid, $unpaid);
     $cache->store($data);
     return Response::json($data);
 }
Example #15
0
 /**
  * Register new department
  *
  * @param $name
  * @param Closure $callback
  * @return $this
  */
 public function department($name, Closure $callback)
 {
     $department = $this->createDepartment($name);
     call_user_func($callback, $department);
     if (is_null(static::$departments)) {
         static::$departments = Collection::make([]);
     }
     static::$departments->push($department);
     return $this;
 }
 /**
  * Add a javascript dependency on the view.
  *
  * @param string $js
  *
  * @throws AssetNotFoundException
  *
  * @return $this
  */
 public function addJs($js)
 {
     if (is_array($js)) {
         foreach ($js as $script) {
             $this->addJs($script);
         }
         return $this;
     }
     $this->js->push($js);
     return $this;
 }
Example #17
0
 protected function playRound()
 {
     $round = new Round($this->player1, $this->player2);
     try {
         $round->play();
         $round->victor()->capture($round->cardsPlayed());
         $this->rounds->push($round);
     } catch (NoCardsToPlayException $e) {
         $this->endGame();
     }
 }
 /**
  * @return Collection
  */
 public function getTags()
 {
     $tags = new Collection([new MetaTag('og:audio', $this->getUrl())]);
     if ($this->getSecureUrl() != null) {
         $tags->push(new MetaTag('og:audio:secure_url', $this->getSecureUrl()));
     }
     if ($this->getType() != null) {
         $tags->push(new MetaTag('og:audio:type', $this->getType()));
     }
     return $tags;
 }
Example #19
0
 /**
  * @param $path
  *
  * @return bool
  */
 private function createFile($path)
 {
     if (!file_exists(dirname($path))) {
         mkdir(dirname($path), 0777, true);
     }
     if (touch($path)) {
         $this->filesCreated->push($path);
         return true;
     }
     return false;
 }
Example #20
0
 /**
  *
  * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
  */
 public function search()
 {
     $results = new Collection();
     $reference = \Request::get('reference');
     $data = \Request::get('data');
     $dateFrom = \Request::get('from');
     $dateTo = \Request::get('to');
     $filters = [];
     $time = ' 23:59:59';
     if (!empty($dateFrom)) {
         $filters[] = ['created_at', '>=', $dateFrom . $time];
     }
     if (!empty($dateTo)) {
         $filters[] = ['created_at', '<=', $dateTo . $time];
     }
     $jobs = [];
     $stages = [];
     $query = "";
     $search = false;
     $jobFilters = $filters;
     $stageFilters = $filters;
     if (!empty($reference)) {
         $jobFilters[] = ['reference', $reference];
         $search = true;
     }
     if (!empty($data)) {
         $jobFilters[] = ['data', 'LIKE', '%' . $data . '%'];
         $stageFilters[] = ['data', 'LIKE', '%' . $data . '%'];
         $search = true;
     }
     if (sizeof($filters) > 0) {
         $search = true;
     }
     if ($search === false) {
         return \Redirect::route('connector.dashboard.index');
     }
     $jobs = $this->jobRepo->filter($jobFilters);
     if (!empty($data)) {
         $stages = $this->stageRepo->filter($stageFilters);
     } else {
         $stages = [];
     }
     foreach ($jobs as $job) {
         $results->push(new JobPresenter($job));
     }
     foreach ($stages as $stage) {
         $results->push(new StagePresenter($stage));
     }
     $results = $results->sort(function ($a, $b) {
         return strtotime($a->created_at) > strtotime($b->created_at) ? 1 : 0;
     });
     return \View::make('connector::search.results', ['results' => $results]);
 }
 /**
  * @return \Illuminate\Support\Collection
  */
 public function getTags()
 {
     $tags = new Collection([new TitleTag($this->title .= config('seo.title_suffix')), new MetaTag('description', $this->description)]);
     if (is_array($this->keywords)) {
         foreach ($this->keywords as $keyword) {
             $tags->push(new MetaTag('keywords', $keyword));
         }
     } else {
         $tags->push(new MetaTag('keywords', $this->keywords));
     }
     return $tags;
 }
Example #22
0
 /**
  * @param Record $record
  * @param null $keyed_by
  */
 public function addRecord(Record $record, $keyed_by = null)
 {
     // register this Results object as the record's parent automatically
     $record->setParent($this);
     $this->returned_results_count++;
     if (is_callable($keyed_by)) {
         $this->results->put($keyed_by($record), $record);
     } elseif ($keyed_by) {
         $this->results->put($record->get($keyed_by), $record);
     } else {
         $this->results->push($record);
     }
 }
Example #23
0
 public function getAmaotoFlow()
 {
     $flow = new Collection();
     Music::orderByRaw('RAND()')->take(10)->get()->each(function ($item) use(&$flow) {
         /** @var Music $item */
         $flow->push(['type' => 'music', 'data' => $item->toArray()]);
     });
     Album::orderByRaw('RAND()')->take(10)->get()->each(function ($item) use(&$flow) {
         /** @var Album $item */
         $flow->push(['type' => 'album', 'data' => $item->toArray()]);
     });
     $result = $flow->shuffle();
     return $this->buildResponse(trans('api.system.get-amaoto-flow.success'), Tools::toArray($result));
 }
 /**
  * Get the groups filters data.
  *
  * @return \Illuminate\Support\Collection
  */
 private function getFilters()
 {
     $filters = new Collection();
     foreach ($this->getCachedPermissionGroups() as $group) {
         /** @var  \Arcanesoft\Auth\Models\PermissionsGroup  $group */
         $filters->push(['name' => $group->name, 'params' => [$group->hashed_id]]);
     }
     // Custom Permission group
     //----------------------------------
     if (Permission::where('group_id', 0)->count()) {
         $filters->push(['name' => 'Custom', 'params' => [hasher()->encode(0)]]);
     }
     return $filters;
 }
Example #25
0
 protected function getOptionElements()
 {
     $option_elements = new Collection();
     foreach ($this->evaluate($this->options) as $options) {
         foreach ($options as $value => $option) {
             if ($option instanceof Collection and is_string($value)) {
                 $option_elements->push($this->generateOptgroupElement($value, $option));
             } else {
                 $option_elements->push($this->generateOptionElement($value, $option));
             }
         }
     }
     return $option_elements;
 }
 /**
  * Execute the command.
  *
  * @return void
  */
 public function fire()
 {
     $this->generators = new Collection();
     $modelGenerator = new ModelGenerator(['name' => $this->argument('name'), 'fillable' => $this->option('fillable'), 'force' => $this->option('force')]);
     $this->generators->push($modelGenerator);
     $this->generators->push(new RepositoryInterfaceGenerator(['name' => $this->argument('name')]));
     $model = $modelGenerator->getRootNamespace() . $modelGenerator->getName();
     $model = str_replace(["\\", '/'], '\\', $model);
     $this->generators->push(new RepositoryEloquentGenerator(['name' => $this->argument('name'), 'rules' => $this->option('rules'), 'model' => $model]));
     foreach ($this->generators as $generator) {
         $generator->run();
     }
     $this->info("Repository created successfully.");
 }
Example #27
0
 /**
  * Generate GraphQL Schema.
  *
  * @return \GraphQL\Schema
  */
 public function buildSchema()
 {
     // Initialize types
     $this->types()->each(function ($type, $key) {
         $type = $this->type($key);
         if (method_exists($type, 'getInterfaces') && !empty($type->getInterfaces())) {
             $this->typesWithInterfaces->push($type);
         }
     });
     $queryFields = $this->queries()->merge($this->connections()->toArray());
     $mutationFields = $this->mutations();
     $queryType = $this->generateSchemaType($queryFields, 'Query');
     $mutationType = $this->generateSchemaType($mutationFields, 'Mutation');
     return new Schema(['query' => $queryType, 'mutation' => $mutationType, 'types' => $this->typesWithInterfaces->all()]);
 }
Example #28
0
 /**
  * Extend the rate limiter by adding a new throttle.
  *
  * @param callable|\Dingo\Api\Http\RateLimit\Throttle $throttle
  *
  * @return void
  */
 public function extend($throttle)
 {
     if (is_callable($throttle)) {
         $throttle = call_user_func($throttle, $this->container);
     }
     $this->throttles->push($throttle);
 }
 public function postCalculateMatch($slug, $id, Request $request)
 {
     $tournament = KTournament::enabled()->whereSlug($slug)->first();
     $match = KMatch::find($id);
     if (!$tournament || !$match) {
         abort(404);
     }
     //If has enough permissions or not
     if (!$request->user()->canManageTournament($tournament)) {
         return redirect()->home();
     }
     if ($match->has_been_played) {
         return redirect()->route('tournament.bracket.show', [$tournament->slug])->with('error', "Error! Already calculated, Plz contact admin for support");
     }
     $collection = new Collection();
     $i = 1;
     foreach ($request->game_id as $game_id) {
         //If game_id is 0 means game is not played
         if ($game_id == 0) {
             $game = new Game();
             $game->game_index = $i;
             $game->is_played = false;
         } else {
             //Get the game
             $game = Game::findOrFail($game_id);
             $game->game_index = $i;
             $game->is_played = true;
         }
         $i++;
         $collection->push($game);
     }
     //dd($collection);
     return view('tournament.manage.getcalculate2')->with('tournament', $tournament)->with('match', $match)->with('games', $collection);
 }
Example #30
0
 /**
  * Generate documentation with the name and version.
  *
  * @param string $name
  * @param string $version
  *
  * @return bool
  */
 public function generate(Collection $controllers, $name, $version)
 {
     $resources = $controllers->map(function ($controller) use($version) {
         $controller = $controller instanceof ReflectionClass ? $controller : new ReflectionClass($controller);
         $actions = new Collection();
         // Spin through all the methods on the controller and compare the version
         // annotation (if supplied) with the version given for the generation.
         // We'll also build up an array of actions on each resource.
         foreach ($controller->getMethods() as $method) {
             if ($versionAnnotation = $this->reader->getMethodAnnotation($method, Annotation\Versions::class)) {
                 if (!in_array($version, $versionAnnotation->value)) {
                     continue;
                 }
             }
             if ($annotations = $this->reader->getMethodAnnotations($method)) {
                 if (!$actions->contains($method)) {
                     $actions->push(new Action($method, new Collection($annotations)));
                 }
             }
         }
         $annotations = new Collection($this->reader->getClassAnnotations($controller));
         return new Resource($controller->getName(), $controller, $annotations, $actions);
     });
     return $this->generateContentsFromResources($resources, $name);
 }