$customerName = Customer::where('id', '=', Input::get('customerID'))->first()->customer_name;
$created_at = Customer::where('id', '=', Input::get('customerID'))->first()->created_at;
我想知道如何在一个查询中获取这两个值(customer_name和created_at)
答案 0 :(得分:1)
我在doc中找到了这种方式:
Customer::where('id', '=', Input::get('customerID'))->lists('customer_name', 'created_at');
答案 1 :(得分:1)
我使用此代码但不确定是否优化
$customerID = Input::get('customerID');
$customer = Customer::findOrFail($customerID);
$customerName = $customer->customer_name;
$created_at = $customer->created_at;