当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::push方法代码示例

本文整理汇总了PHP中Illuminate\Support\Collection::push方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::push方法的具体用法?PHP Collection::push怎么用?PHP Collection::push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Collection的用法示例。


在下文中一共展示了Collection::push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register

 /**
  * Register the location.
  *
  * @return void
  */
 public function register()
 {
     if (empty($this->migrate)) {
         return false;
     }
     $this->locations->push([$this->migrate, $this->using ?: null]);
 }
开发者ID:apolune,项目名称:core,代码行数:12,代码来源:MigrationHandler.php

示例2: addRow

 /**
  * 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);
 }
开发者ID:palmabit,项目名称:catalog,代码行数:13,代码来源:Order.php

示例3: addCategory

 /**
  * @param CategoryModel $category
  */
 public function addCategory(CategoryModel $category)
 {
     // spent is minus zero for an expense report:
     if ($category->spent < 0) {
         $this->categories->push($category);
     }
 }
开发者ID:zetaron,项目名称:firefly-iii,代码行数:10,代码来源:Category.php

示例4: auxiliarLibros

 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'));
 }
开发者ID:armandolazarte,项目名称:guia,代码行数:32,代码来源:ConciliacionBancariaController.php

示例5: getTest

 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());
 }
开发者ID:Cadrach,项目名称:dimensions,代码行数:60,代码来源:PlotterController.php

示例6: getTotalUpcomingSchedulesAttribute

 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;
 }
开发者ID:ThunderID,项目名称:capcus.v2,代码行数:35,代码来源:Destination.php

示例7: insert

 /**
  * 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;
 }
开发者ID:inoplate,项目名称:auth,代码行数:13,代码来源:Permission.php

示例8: generateMenu

 /**
  * @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;
     });
 }
开发者ID:wearejust,项目名称:shapeshifter,代码行数:32,代码来源:MenuService.php

示例9: addItem

 public function addItem(AbstractItem $item)
 {
     if (is_null($this->items)) {
         $this->items = new Collection();
     }
     $this->items->push($item);
 }
开发者ID:howlowck,项目名称:pipboy-unit,代码行数:7,代码来源:User.php

示例10: addColumn

 public function addColumn($column)
 {
     if (NULL === $this->columns) {
         $this->columns = Collection::make([]);
     }
     $this->columns->push($column);
     return $this;
 }
开发者ID:mage2,项目名称:project-management-system,代码行数:8,代码来源:DataGrid.php

示例11: push

 public function push(Event $event, array $customAttributes = [])
 {
     if (!empty($customAttributes)) {
         $this->events->push($this->convertToArray($event, $customAttributes));
     } else {
         $this->events->push($event);
     }
 }
开发者ID:pisizt,项目名称:laravel-fullcalendar,代码行数:8,代码来源:EventCollection.php

示例12: add

 public function add(array $message, $flash = true)
 {
     $this->messages->push($message);
     if ($flash) {
         $this->session->flash('__messages', $this->messages);
     }
     return $this;
 }
开发者ID:portonefive,项目名称:essentials,代码行数:8,代码来源:MessageManager.php

示例13: html

 public function html($value = null)
 {
     if ($value == null) {
         return $this->buildChildren();
     }
     $value = value($value);
     $this->children = new Collection();
     $this->children->push($value);
 }
开发者ID:cocona,项目名称:core,代码行数:9,代码来源:Element.php

示例14: frontpage

 /**
  * 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);
 }
开发者ID:ebbz,项目名称:firefly-iii,代码行数:64,代码来源:BillController.php

示例15: department

 /**
  * 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;
 }
开发者ID:adminarchitect,项目名称:contacts,代码行数:17,代码来源:Contacts.php


注:本文中的Illuminate\Support\Collection::push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。