本文整理汇总了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();
}
示例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());
}
示例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);
}
示例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);
}
示例5: add
/**
* @param $discount
*/
public function add($discount)
{
$this->discounts->push($discount);
}
示例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;
}
示例7: push
public function push($value)
{
$this->load();
return parent::push($value);
}
示例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());
}
}
示例9: push
/**
* @param mixed $item
* @return void
*/
public function push($item)
{
$this->assertStrictType($item);
parent::push($item);
}
示例10: pushCriteria
/**
* @param Criteria $criteria
* @return $this
*/
public function pushCriteria(Criteria $criteria)
{
$this->criteria->push($criteria);
return $this;
}
示例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>