Пример #1
0
 /**
  * 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
0
function collection()
{
    $collection = new collection();
    $args = func_get_args();
    foreach ($args as $arg) {
        $collection->push($arg);
    }
    return $collection;
}
 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
0
	/**
	*	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;
	}