本文整理汇总了PHP中app\Customer::whereNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::whereNull方法的具体用法?PHP Customer::whereNull怎么用?PHP Customer::whereNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Customer
的用法示例。
在下文中一共展示了Customer::whereNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
if (Gate::denies('customer.read')) {
return view(config('app.template') . '.error.403');
}
$type = $request->get('type') ? $request->get('type') : 'registered';
if ($type == 'registered') {
$customers = Customer::leftJoin(DB::raw("\n (SELECT orders.`id`, orders.`customer_id`, SUM(order_details.`harga_jual` * (order_details.`qty` - ifnull(order_detail_returns.qty, 0)))\n AS total_penjualan FROM orders INNER JOIN order_details ON orders.`id` = order_details.`order_id`\n LEFT JOIN order_detail_returns on order_details.id = order_detail_returns.order_detail_id\n WHERE orders.`state` = 'Closed' GROUP BY orders.`id`)AS temp_orders\n "), 'customers.id', '=', 'temp_orders.customer_id')->whereNotNull('customers.nama')->select(['customers.*', DB::raw('count(temp_orders.id) as jumlah_kunjungan'), DB::raw('sum(temp_orders.total_penjualan)as total')])->groupBy('customers.id')->paginate(2);
$data = ['customers' => $customers];
return view(config('app.template') . '.customer.table', $data);
} elseif ($type == 'unregistered') {
$customers = Customer::whereNull('nama')->get();
$data = ['customers' => $customers];
return view(config('app.template') . '.customer.table-empty', $data);
} else {
abort(404);
}
}