本文整理汇总了PHP中app\models\Customer::id方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::id方法的具体用法?PHP Customer::id怎么用?PHP Customer::id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Customer
的用法示例。
在下文中一共展示了Customer::id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: detail
/**
* Display a customer
*
* @return Response
*/
public function detail($id = null)
{
$result = \App\Models\Customer::id($id)->with(['sales', 'myreferrals', 'myreferrals.user'])->first();
if ($result) {
return new JSend('success', (array) $result->toArray());
}
return new JSend('error', (array) Input::all(), 'ID Tidak Valid.');
}
示例2: invite
/**
* Invite friend
*
* @return Response
*/
public function invite($user_id = null)
{
if (!Input::has('invitations')) {
return new JSend('error', (array) Input::all(), 'Tidak ada data invitations.');
}
$invitations = Input::get('invitations');
$errors = new MessageBag();
DB::beginTransaction();
//1. Store mail
if (!$errors->count()) {
foreach ($invitations as $key => $value) {
if (!$errors->count()) {
$log_data = new \App\Models\UserInvitationLog();
$log_rules = ['email' => 'required|email'];
$validator = Validator::make($value, $log_rules);
//if there was log and validator false
if (!$validator->passes()) {
$errors->add('log', $validator->errors());
} else {
$value['user_id'] = $user_id;
$log_data = $log_data->fill($value);
if (!$log_data->save()) {
$errors->add('Log', $log_data->getError());
}
}
}
}
}
if ($errors->count()) {
DB::rollback();
return new JSend('error', (array) Input::all(), $errors);
}
DB::commit();
$final_costumer = \App\Models\Customer::id($user_id)->with(['myreferrals', 'myreferrals.user'])->first()->toArray();
return new JSend('success', (array) $final_costumer);
}
示例3: change
/**
* Change password
*
* @return Response
*/
public function change()
{
if (!Input::has('email') || !Input::has('password')) {
return new JSend('error', (array) Input::all(), 'Tidak ada data customer.');
}
$email = Input::get('email');
$password = Input::get('password');
$errors = new MessageBag();
DB::beginTransaction();
//1. Check Email
$customer_data = \App\Models\Customer::email($email)->notSSOMedia(['facebook'])->first();
if (!$customer_data) {
$errors->add('Customer', 'Email tidak valid.');
} elseif (empty($customer_data->reset_password_link)) {
$errors->add('Customer', 'Email tidak valid.');
} else {
//if validator passed, save customer
$customer_data = $customer_data->fill(['reset_password_link' => '', 'password' => $password, 'date_of_birth' => strtotime($customer_data['date_of_birth']) ? $customer_data['date_of_birth']->format('Y-m-d H:i:s') : '']);
if (!$customer_data->save()) {
$errors->add('Customer', $customer_data->getError());
}
}
if ($errors->count()) {
DB::rollback();
return new JSend('error', (array) Input::all(), $errors);
}
DB::commit();
$final_customer = \App\Models\Customer::id($customer_data['id'])->first()->toArray();
return new JSend('success', (array) $final_customer);
}