本文整理汇总了PHP中Plan::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Plan::select方法的具体用法?PHP Plan::select怎么用?PHP Plan::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plan
的用法示例。
在下文中一共展示了Plan::select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Get all transactions
*/
public function search($params = NULL)
{
$_tbl_transactions = Transaction::getTableName();
$_tbl_purchases = Purchase::getTableName();
$_tbl_products = Product::getTableName();
$_tbl_plans = Plan::getTableName();
$_tbl_affiliates = Affiliate::getTableName();
$_tbl_buyers = Buyer::getTableName();
// Build search params
if (!$params) {
$this->_build_search_params();
} else {
$this->setSearchParams($params);
}
$from = strtotime("midnight", strtotime($this->_search_params['from']));
$to = strtotime("tomorrow", strtotime($this->_search_params['to'])) - 1;
//echo $from . " | " . $to;exit;
$fields = array("{$_tbl_transactions}.*", "{$_tbl_purchases}.affiliate_id", "{$_tbl_purchases}.product_id", "{$_tbl_products}.name AS product_name", "{$_tbl_plans}.name AS plan_name", "{$_tbl_affiliates}.name AS affiliate_name", "{$_tbl_buyers}.first_name AS buyer_first_name", "{$_tbl_buyers}.last_name AS buyer_last_name", "{$_tbl_buyers}.email AS buyer_email");
$transaction = DB::table($_tbl_transactions)->join($_tbl_purchases, "{$_tbl_purchases}.id", '=', "{$_tbl_transactions}.purchase_id")->join($_tbl_products, "{$_tbl_products}.id", '=', "{$_tbl_purchases}.product_id")->join($_tbl_plans, "{$_tbl_plans}.id", '=', "{$_tbl_transactions}.plan_id")->join($_tbl_buyers, "{$_tbl_buyers}.id", '=', "{$_tbl_purchases}.buyer_id")->leftJoin($_tbl_affiliates, "{$_tbl_affiliates}.id", '=', "{$_tbl_purchases}.affiliate_id")->select($fields);
$transaction = $transaction->orderBy('created_at', 'DESC');
if (!$this->_search_params['paid'] or !$this->_search_params['refunded']) {
if ($this->_search_params['paid'] and !$this->_search_params['refunded']) {
$is_refunded = FALSE;
}
if (!$this->_search_params['paid'] and $this->_search_params['refunded']) {
$is_refunded = TRUE;
}
if (isset($is_refunded)) {
$transaction = $transaction->where("is_refunded", '=', $is_refunded);
}
}
if ($this->_search_params['product']) {
// Get All Plan IDs
$plans = Plan::select('id')->where("product_id", '=', $this->_search_params['product'])->get();
$planArr = array();
foreach ($plans as $plan) {
$planArr[] = $plan->id;
}
$transaction = $transaction->whereIn("{$_tbl_transactions}.plan_id", $planArr);
}
if ($this->_search_params['affiliate']) {
if ($this->_search_params['affiliate'] == "no-affiliate") {
$transaction = $transaction->where("{$_tbl_purchases}.affiliate_id", '=', NULL);
} else {
$transaction = $transaction->where("{$_tbl_purchases}.affiliate_id", '=', $this->_search_params['affiliate']);
}
}
// Quick Search
if ($this->_search_params['q']) {
$transaction = $transaction->orWhere("{$_tbl_buyers}.email", '=', $this->_search_params['q'])->orWhere("{$_tbl_buyers}.first_name", 'LIKE', $this->_search_params['q'] . "%")->orWhere("{$_tbl_buyers}.last_name", 'LIKE', $this->_search_params['q'] . "%")->orWhere(DB::raw('CONCAT(' . $_tbl_buyers . '.first_name," ",' . $_tbl_buyers . '.last_name)'), 'LIKE', $this->_search_params['q'] . "%")->orWhere("{$_tbl_transactions}.pay_id", 'LIKE', "%" . $this->_search_params['q'] . "%");
}
// Email Search
if (!empty($this->_search_params['email'])) {
$transaction = $transaction->where("{$_tbl_buyers}.email", '=', $this->_search_params['email']);
}
$transaction = $transaction->whereBetween("{$_tbl_transactions}.updated_at", array($from, $to));
return $transaction->paginate(25);
}