本文整理汇总了PHP中collection::push方法的典型用法代码示例。如果您正苦于以下问题:PHP collection::push方法的具体用法?PHP collection::push怎么用?PHP collection::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collection
的用法示例。
在下文中一共展示了collection::push方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: includes
/**
* Itterate over object, build a relations, fillable and includes collection.
*
* @param model $object the model to iterate over
*
* @return array
*/
private function includes($object)
{
$fillable = $object->getFillable();
$includes = $object->getIncludes();
$table = $object->getTable();
$columns = $object->columns();
$results[$table] = [];
if (!empty($includes)) {
foreach ($includes as $include) {
$results[$table] = ['object' => $object, 'includes' => $this->includes(new $include())];
}
}
$this->fillables->put($table, $fillable);
$this->includes->push($table, $table);
$this->columns->put($table, $columns);
return $results;
}
示例2: collection
function collection()
{
$collection = new collection();
$args = func_get_args();
foreach ($args as $arg) {
$collection->push($arg);
}
return $collection;
}
示例3: plansDatatablesAjaxHandler
public function plansDatatablesAjaxHandler(Request $request)
{
if ($request->input('method') == "first") {
$objModelPlan = Plan::getInstance();
$whereForPlans = array('rawQuery' => 'status = 1 or status = 0');
$planLists = $objModelPlan->getAllPlansWhere($whereForPlans);
$planLists = json_decode(json_encode($planLists), true);
$plans = new collection();
foreach ($planLists as $aap) {
$id = $aap['plan_id'];
$statusClass = $aap['status'] == 1 ? 'fa fa-check-circle' : 'fa fa-times-circle';
$color = $aap['status'] == 1 ? 'green' : 'red';
$text = $aap['status'] == 1 ? 'Active' : 'Inactive';
$bgcolor = $aap['status'] == 1 ? 'lightgreen' : 'lightpink';
$plans->push(['service' => $aap['plan_name'], 'min' => $aap['min_quantity'], 'max' => $aap['max_quantity'], 'ratepk' => $aap['charge_per_unit'], 'status' => '<div class="switch" id="status" data-id="' . $id . '" style="background-color:' . $color . '" >
<input id=' . $id . ' class="cmn-toggle cmn-toggle-yes-no" type="checkbox" style="background-color:' . $color . '">
<label for=' . $id . ' data-text="' . $text . '"></label>
</div>', 'edit' => '<a href="/admin/plans-list-edit/' . $aap['plan_id'] . '" class="btn btn-sm btn-warning">Edit</a>']);
}
return Datatables::of($plans)->make(true);
} else {
if ($request->input('method') == "second") {
$planType = $request->input('planType');
$serviceType = $request->input('serviceType');
$objModelPlans = Plan::getInstance();
if ($planType == 5 && $serviceType == 5) {
$where = array('rawQuery' => 'status = 1 or status = 0');
} elseif ($planType == 5 && $serviceType != 5) {
$where = array('rawQuery' => 'plan_type IN (0,1,3,4) and service_type=?', 'bindParams' => [$serviceType]);
} elseif ($planType != 5 && $serviceType == 5) {
$where = array('rawQuery' => 'service_type IN ("R","F","T") and plan_type =?', 'bindParams' => [$planType]);
} else {
$where = array('rawQuery' => 'plan_type=? and service_type=?', 'bindParams' => [$planType, $serviceType]);
}
$planLists = $objModelPlans->getAllPlansWhere($where);
$planLists = json_decode(json_encode($planLists), true);
$plans = new collection();
foreach ($planLists as $aap) {
$id = $aap['plan_id'];
$statusClass = $aap['status'] == 1 ? 'fa fa-check-circle' : 'fa fa-times-circle';
$color = $aap['status'] == 1 ? 'green' : 'red';
$bgcolor = $aap['status'] == 1 ? 'lightgreen' : 'lightpink';
$plans->push(['service' => $aap['plan_name'], 'min' => $aap['min_quantity'], 'max' => $aap['max_quantity'], 'ratepk' => $aap['charge_per_unit'], 'status' => '<a href="javascript:;" id="status" class="btn btn-sm btn-raised ' . $statusClass . '" style="color:' . $color . '; background-color:' . $bgcolor . '" data-id=' . $id . ' ></a>', 'edit' => '<a href="/admin/plans-list-edit/' . $aap['plan_id'] . '" class="btn btn-sm btn-warning">Edit</a>']);
}
return Datatables::of($plans)->make(true);
}
}
}
示例4: data
/**
* Retrieves the data produced by query/queries
* @access public
* @return [array|integer] - cases:
* - MULTI-QUERY: multi-dimensional array, one outer array per query result
* - PREPARED/ASYNC/EXECUTE - single dimension array of results
* - INSERT operation: insert_id
*/
public function data($name=NULL)
{
if(!is_null($this->stmt))
{
$this->_stmt_data();
}
else if($this->is_async)
{
$this->_async_data();
}
$historical_entry = new collection($name);
$historical_entry->push($this->result);
$this->history->push($historical_entry);
$retval = $this->result;
$this->reset;
return $retval;
}