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


PHP Collection::push方法代码示例

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


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

示例1: addEvent

 /**
  * Insert a new event into the timeline. This should make our cache dirty.
  *
  * @param TicketEvent $event The new event for our timeline
  */
 public function addEvent(TicketEvent $event)
 {
     $this->timeline->push($event);
     // Set up some circular-referencing
     $event->setTicket($this);
     // Fire off our events
     $event_name = 'ticket-' . str_replace(' ', '-', $event->getAction());
     $this->getEventManager()->dispatch($event_name, $event);
     $this->getEventManager()->dispatch('ticket-add-event', $event);
     $this->setDirty();
 }
开发者ID:consolidate,项目名称:ticket,代码行数:16,代码来源:Ticket.php

示例2: testPopPushPutShiftUnshiftInject

 public function testPopPushPutShiftUnshiftInject()
 {
     // pop
     $_3 = $this->collection->pop();
     $this->assertEquals($this->_3, $_3);
     $this->assertEquals($this->_2, $this->collection->last());
     $this->assertEquals(3, $this->collection->count());
     // push
     $this->collection->push($_3);
     $this->assertEquals($this->_3, $this->collection->last());
     // put
     $this->collection->put(2, 'test');
     $this->assertEquals('test', $this->collection->get(2));
     // shift
     $_0 = $this->collection->shift();
     $this->assertEquals($this->_0, $_0);
     $this->assertEquals($this->_1, $this->collection->first());
     $this->assertEquals(3, $this->collection->count());
     // unshift
     $this->collection->unshift($_0);
     $this->assertEquals($this->_0, $this->collection->first());
     // inject
     $this->collection->inject(2, 'test2');
     $this->assertEquals('test2', $this->collection->get(2));
     $this->assertEquals(5, $this->collection->count());
 }
开发者ID:dtkahl,项目名称:php-array-tools,代码行数:26,代码来源:CollectionTest.php

示例3: getAppointmentForModalEdit

 public function getAppointmentForModalEdit(Request $request)
 {
     if ($request->session()->get('global_branch') == 'all') {
         $dentists = User::where('level_id', 2)->get();
     } else {
         $dentist_ids = DB::table('branch_dentists')->select('dentist_id')->where('branch_id', $request->session()->get('global_branch'))->get();
         $dentists = new Collection();
         foreach ($dentist_ids as $dentist_id) {
             $dentist = User::findOrFail($dentist_id->dentist_id);
             $dentists->push($dentist);
         }
     }
     $appointment = Appointment::findOrFail($request->input('appointment_id'));
     $vars = array("appointment" => $appointment, "dentists" => $dentists);
     $html = view('backend.dialogs.edit_appointment_dialog')->with($vars)->render();
     $response = array('status' => 'success', 'html' => $html);
     return json_encode($response);
 }
开发者ID:VoodooPrawn,项目名称:finest,代码行数:18,代码来源:AppointmentController.php

示例4: showTicketsAjaxHandler

 public function showTicketsAjaxHandler()
 {
     $userId = Session::get('ig_supplier')['id'];
     $objUserTicket = Ticket::getInstance();
     $where = array('rawQuery' => 'user_id=?', 'bindParams' => [$userId]);
     $selectedColumns = array('users.*', 'tickets.*');
     $ticketDetailsOfUser = $objUserTicket->getUserInfoByUserId($where, $selectedColumns);
     //        dd($ticketDetailsOfUser);
     $tickets = new Collection();
     $ticketDetailsOfUser = json_decode(json_encode($ticketDetailsOfUser), true);
     foreach ($ticketDetailsOfUser as $tdu) {
         $id = $tdu['ticket_id'];
         if ($tdu['ticket_status'] == 0) {
             $status = 'opened';
         } else {
             $status = 'closed';
         }
         $tickets->push(['ticket_id' => $tdu['ticket_id'], 'name' => $tdu['name'] . $tdu['lastname'], 'email' => $tdu['email'], 'subject' => $tdu['subject'], 'descriptions' => $tdu['descriptions'], 'status' => $status, 'created_at' => $tdu['created_at']]);
     }
     return Datatables::of($tickets)->make(true);
 }
开发者ID:sumitglobussoft,项目名称:INSTAGRAM-PANEL,代码行数:21,代码来源:TicketsController.php

示例5: add

 /**
  * @param $discount
  */
 public function add($discount)
 {
     $this->discounts->push($discount);
 }
开发者ID:draperstudio,项目名称:basket,代码行数:7,代码来源:Coupon.php

示例6: filterRecursive

 /**
  * Filter items recursively
  *
  * @param string $attribute
  * @param mixed  $value
  *
  * @return Lavary\Menu\Collection
  */
 public function filterRecursive($attribute, $value)
 {
     $collection = new Collection();
     // Iterate over all the items in the main collection
     $this->items->each(function ($item) use($attribute, $value, &$collection) {
         if (!$this->hasProperty($attribute)) {
             return false;
         }
         if ($item->{$attribute} == $value) {
             $collection->push($item);
             // Check if item has any children
             if ($item->hasChildren()) {
                 $collection = $collection->merge($this->filterRecursive($attribute, $item->id));
             }
         }
     });
     return $collection;
 }
开发者ID:lavary,项目名称:laravel-menu,代码行数:26,代码来源:Builder.php

示例7: push

 public function push($value)
 {
     $this->load();
     return parent::push($value);
 }
开发者ID:sp1ke77,项目名称:MLM-1,代码行数:5,代码来源:VirtualCollection.php

示例8: postStore

 public function postStore($id = null)
 {
     // ---------------------------------------- HANDLE REQUEST ----------------------------------------
     // handle id
     if (!is_null($id)) {
         $data = $this->model->findorfail($id);
     } else {
         $data = $this->model->newInstance();
     }
     // ---------------------------------------- CHECK TAG ----------------------------------------
     $tags_in_db = \App\Tag::whereIn('tag', Input::get('tags'))->get();
     if (!$tags_in_db) {
         $tags_in_db = new Collection();
     }
     foreach (Input::get('tags') as $x) {
         if (!$tags_in_db->where('tag', $x)->first()->id) {
             $new_tag = new \App\Tag(['tag' => $x]);
             if (!$new_tag->save()) {
                 dd($new_tag->getErrors());
             }
             $tags_in_db->push($new_tag);
         }
     }
     // ---------------------------------------- HANDLE SAVE ----------------------------------------
     $input = Input::all();
     if (!empty($input['published_at'])) {
         $input['published_at'] = \Carbon\Carbon::createFromFormat('d/m/Y H:i', $input['published_at'])->format('Y-m-d H:i:s');
     } else {
         $input['published_at'] = null;
     }
     unset($input['longlat']);
     $input['tag_ids'] = $tags_in_db->pluck('id')->toArray();
     $data->fill($input);
     if ($data->save()) {
         if (!$this->save_required_images($data, $input)) {
             return redirect()->back()->withInput()->withErrors($data->getErrors());
         }
         return redirect()->route('admin.' . $this->view_name . '.show', ['id' => $data->id])->with('alert_success', '"' . $data->{$data->getNameField()} . '" has been saved successfully');
     } else {
         return redirect()->back()->withInput()->withErrors($data->getErrors());
     }
 }
开发者ID:ThunderID,项目名称:capcus.v2,代码行数:42,代码来源:PlaceController.php

示例9: push

 /**
  * @param mixed $item
  * @return void
  */
 public function push($item)
 {
     $this->assertStrictType($item);
     parent::push($item);
 }
开发者ID:rwillians,项目名称:collection,代码行数:9,代码来源:StrictTypedCollection.php

示例10: pushCriteria

 /**
  * @param Criteria $criteria
  * @return $this
  */
 public function pushCriteria(Criteria $criteria)
 {
     $this->criteria->push($criteria);
     return $this;
 }
开发者ID:acmadi,项目名称:MinionCMS,代码行数:9,代码来源:BaseRepository.php

示例11: generateMSPRHTML


//.........这里部分代码省略.........
    if ($component && $component->count() > 0) {
        $research_no = 0;
        ?>
				<h3><u>Publications</u></h3>
				<i>Students are encouraged to pursue extracurricular research endeavours to enrich their academic experience. Research undertaken during the medical program appears below.</i><br><br>
				<table width="100%" border=0 cellpadding=5 cellspacing=0>
				<?php 
        foreach ($component as $entity) {
            if (++$research_no > MAX_RESEARCH) {
                break;
            }
            ?>
					<tr>
						<td valign="top"><?php 
            echo nl2br($entity->getText());
            ?>
</td>
					</tr>
					<?php 
        }
        ?>
				</table>
				<br>
				<?php 
    }
    $internal_awards = $mspr["Internal Awards"];
    $external_awards = $mspr["External Awards"];
    if ($external_awards) {
        $external_awards->filter("is_approved");
    }
    $component = new Collection();
    if ($internal_awards) {
        foreach ($internal_awards as $award) {
            $component->push($award);
        }
    }
    if ($external_awards) {
        foreach ($external_awards as $award) {
            $component->push($award);
        }
    }
    $component->sort("year", "asc");
    if ($component->count() > 0) {
        ?>
				<h3><u>Academic Awards</u></h3>
				<i>A brief summary of the terms of reference accompanies each award. Only items of academic significance and either acknowledged or awarded by Queen's University are presented.</i><br><br>
				<table width="100%" border=0 cellpadding=5 cellspacing=0>
				<?php 
        foreach ($component as $entity) {
            $award = $entity->getAward();
            ?>
					<tr>
						<td valign="top" width="50%"><?php 
            echo $award->getTitle();
            ?>
</td>
						<td valign="top" width="50%" align="right"><?php 
            echo $entity->getAwardYear();
            ?>
</td>
					</tr>
					<tr>
						<td valign="top" colspan=2><blockquote><?php 
            echo nl2br($award->getTerms());
            ?>
</blockquote></td>
开发者ID:nadeemshafique,项目名称:entrada-1x,代码行数:67,代码来源:mspr_gen.php


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