本文整理汇总了PHP中app\Customer::salesman方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::salesman方法的具体用法?PHP Customer::salesman怎么用?PHP Customer::salesman使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Customer
的用法示例。
在下文中一共展示了Customer::salesman方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
//
$rules = array('projectNum' => 'required', 'create_at' => 'required', 'pjsales' => 'required', 'pjContacter' => 'required', 'pjContacterPhone' => 'required', 'pjContacterEmail' => 'email|required', 'cmCode' => 'required', 'cmShort' => 'required', 'e_shortName' => 'required', 'customer_id' => 'required', 'c_name' => 'required', 'institute' => 'required', 'department' => 'required', 'email' => 'email|required', 'contacter' => 'required', 'contacterPhone' => 'required', 'contacterEmail' => 'email|required', 'address' => 'required', 'sales' => 'required', 'PJclass' => 'required', 'PJservice' => 'required', 'PJspecies' => 'required');
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput();
}
$customer_id = $request->get('customer_id');
if ($customer_id == 0) {
$customer = new Customer(array('cmCode' => $request->get('cmCode'), 'cmShort' => $request->get('cmShort'), 'c_name' => $request->get('c_name'), 'e_shortName' => $request->get('e_shortName'), 'institute' => $request->get('institute'), 'department' => $request->get('department'), 'fax' => $request->get('fax'), 'phone' => $request->get('phone'), 'email' => $request->get('email'), 'contacter' => $request->get('contacter'), 'contacterPhone' => $request->get('contacterPhone'), 'contacterEmail' => $request->get('contacterEmail'), 'address' => $request->get('address'), 'salesman' => $request->get('sales')));
$salesman = User::findOrFail($request->get('sales'));
$customer->salesman()->associate($salesman);
$customer->save();
} else {
$customer = Customer::findOrFail($customer_id);
$customer->update(['cmCode' => $request->get('cmCode'), 'cmShort' => $request->get('cmShort'), 'c_name' => $request->get('c_name'), 'e_shortName' => $request->get('e_shortName'), 'institute' => $request->get('institute'), 'department' => $request->get('department'), 'fax' => $request->get('fax'), 'phone' => $request->get('phone'), 'email' => $request->get('email'), 'contacter' => $request->get('contacter'), 'contacterPhone' => $request->get('contacterPhone'), 'contacterEmail' => $request->get('contacterEmail'), 'address' => $request->get('address')]);
$salesman = User::findOrFail($request->get('sales'));
$customer->salesman()->associate($salesman);
$customer->save();
}
$project = Project::findOrFail($id);
if (empty($request->file('file'))) {
$fileName = null;
} else {
$fileName = $project->id . '.' . $request->file('file')->getClientOriginalExtension();
$request->file('file')->move(base_path() . '/storeFiles/ngs/quotation/', $fileName);
}
$user = \Auth::user();
$project->user()->associate($user);
$customer = Customer::findOrFail($customer_id);
$project->customer()->associate($customer);
$pjsalesman = User::findOrFail($request->get('pjsales'));
$project->salesman = $pjsalesman->id;
if ($request->get('PJservice') == 'Other') {
$PJservice = $request->get('PJserviceNote');
} else {
$PJservice = $request->get('PJservice');
}
if (empty($fileName)) {
$project->update(['projectNum' => $request->get('projectNum'), 'PJtype' => $request->get('PJtype'), 'PJclass' => $request->get('PJclass'), 'PJservice' => $PJservice, 'PJspecies' => $request->get('PJspecies'), 'note' => $request->get('note'), 'contacter' => $request->get('contacter'), 'contacterPhone' => $request->get('contacterPhone'), 'contacterEmail' => $request->get('contacterEmail')]);
} else {
$project->update(['projectNum' => $request->get('projectNum'), 'PJtype' => $request->get('PJtype'), 'PJclass' => $request->get('PJclass'), 'PJservice' => $PJservice, 'PJspecies' => $request->get('PJspecies'), 'note' => $request->get('note'), 'contacter' => $request->get('contacter'), 'contacterPhone' => $request->get('contacterPhone'), 'contacterEmail' => $request->get('contacterEmail'), 'fileName' => $fileName]);
}
return \Redirect::to('research/ngs/projects/index')->with('message', 'Your Project has been updated!');
}