本文整理汇总了PHP中app\Customer::firstOrNew方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::firstOrNew方法的具体用法?PHP Customer::firstOrNew怎么用?PHP Customer::firstOrNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Customer
的用法示例。
在下文中一共展示了Customer::firstOrNew方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store the return items data
*
* @return ReturnController@index
*/
public function store()
{
$input = Input::all();
$customer = Customer::firstOrNew(['name' => $input['customer']]);
$customer->address = $input['address'];
$customer->save();
$ret = new Ret();
$ret->customer_id = $customer->id;
$ret->date = $input['date'];
$ret->reference_no = $input['ref_no'];
$ret->salesman = $input['salesman'];
$ret->area = $input['area'];
$ret->received_by = $input['received_by'];
$ret->checked_by = $input['checked_by'];
$ret->save();
foreach ($input['boxes'] as $i => $box) {
$retItem = new ReturnItem();
$retItem->ret_id = $ret->id;
$retItem->box_id = $box;
$retItem->no_of_box = $input['no_of_box'][$i];
$retItem->no_of_packs = $input['no_of_packs'][$i];
$retItem->amount = $input['amount'][$i];
$retItem->product_id = Box::find($box)->product->id;
$retItem->save();
}
return Redirect::action('InventoryController@index');
}
示例2: store
public function store()
{
$input = Input::all();
$salesman = isset($input['salesman']) ? $input['salesman'] : null;
$customer = Customer::firstOrNew(['name' => $input['name'], 'address' => $input['address']]);
$customer->save();
$order = new Order();
$order->customer_id = $customer->id;
$order->salesman_id = $salesman;
$order->date = $input['date'];
$order->type = $input['type'];
$order->save();
foreach ($input['box_id'] as $i => $box_id) {
$orderItem = new OrderItem();
$orderItem->order_id = $order->id;
$orderItem->product_id = Box::find($box_id)->product->id;
$orderItem->box_id = $box_id;
$orderItem->no_of_box = $input['no_of_box'][$i];
$orderItem->no_of_packs = $input['no_of_packs'][$i];
$orderItem->amount = $input['amount'][$i];
$orderItem->selling_price = $input['selling_price'][$i];
$orderItem->save();
}
return view('order.addmore');
}
示例3: store
public function store()
{
$input = Session::get('input');
$customer = Customer::firstOrNew(['name' => $input['order_by']]);
$customer->address = $input['address'];
$customer->save();
return Redirect::action('OrderController@create', compact('input'));
}