本文整理汇总了PHP中app\Customer::leftJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::leftJoin方法的具体用法?PHP Customer::leftJoin怎么用?PHP Customer::leftJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Customer
的用法示例。
在下文中一共展示了Customer::leftJoin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: table
public function table()
{
$operations = ['<li>{!!link_to_route("customers.edit", "edit", ["customerId" => $id], ["class" => "glyphicon glyphicon-pencil"])!!}</li>', '<li>{!!link_to_route("customers.remove", "remove", ["customerId" => $id], ["class" => "glyphicon glyphicon-remove"])!!}</li>'];
$customers = Customer::leftJoin('customer_group', 'customer.group_id', '=', 'customer_group.id')->select(['customer.id', 'customer.firstname', 'customer.lastname', 'customer.phone', 'customer_group.groupname']);
return \Datatables::of($customers)->add_column('operations', '<ul class="operations">' . implode($operations) . '</ul>')->add_column('show', '{{route("customers.show", ["customerId" => $id])}}')->remove_column('id')->make(true);
}
示例3: customerInfo
public function customerInfo(Request $request)
{
$customer = Customer::leftJoin('users', 'users.userable_id', '=', 'customer.id')->select('customer.id', 'username', 'email', 'banned', 'name', 'address', 'phone')->findOrFail($request->id);
return $customer;
}