本文整理汇总了PHP中Students::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Students::with方法的具体用法?PHP Students::with怎么用?PHP Students::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Students
的用法示例。
在下文中一共展示了Students::with方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportSelected
public function exportSelected()
{
$selected_students = Input::get('studentId');
if (is_array($selected_students)) {
//Setup CSV
$csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject());
$column_flag = false;
$student = [];
foreach ($selected_students as $student_id) {
$student_data = Students::with('course')->find($student_id);
//Personal data
$student['firstname'] = $student_data['firstname'];
$student['surname'] = $student_data['surname'];
$student['email'] = $student_data['email'];
//Course data
$student['university'] = $student_data->course['university'];
$student['course_name'] = $student_data->course['course_name'];
//Check whether column headers have been set (not ideal for large datasets)
if ($column_flag === false) {
$csv->insertOne(\Schema::getColumnListing('student'));
$column_flag = true;
}
//Add student record to file
$csv->insertOne($student);
}
} else {
return "NO STUDENTS SELECTED";
}
//is_array($selected_students)
$csv->output("selected_student_records.csv");
}
示例2: getStudentByCustomer
static function getStudentByCustomer($customerId)
{
$students = Students::with('StudentClasses')->where('customer_id', '=', $customerId)->get();
return $students;
}
示例3: enrollKid
//.........这里部分代码省略.........
$neworder['payment_mode'] = 'card';
$neworder['card_type'] = $inputs['cardType3'];
$neworder['card_last_digit'] = $inputs['card4digits3'];
$neworder['bank_name'] = $inputs['cardBankName3'];
$neworder['receipt_number'] = $inputs['cardRecieptNumber3'];
}
}
}
$neworder['created_at'] = $paydue_data['created_at'];
$neworder->created_by = Session::get('userId');
$neworder->save();
}
if ($inputs['CustomerType'] == 'OldCustomer' && $inputs['OrderDate4'] != '' && $inputs['paymentOptionsRadio'] == 'multipay') {
$paydue_data = PaymentDues::where('id', '=', $paydue_id[3])->get();
$paydue_data = $paydue_data[0];
$neworder = new Orders();
$neworder['customer_id'] = $paydue_data['customer_id'];
$neworder['student_id'] = $paydue_data['student_id'];
$neworder['season_id'] = $paydue_data['season_id'];
$neworder['student_classes_id'] = $paydue_data['student_class_id'];
$neworder['payment_for'] = "enrollment";
$neworder['payment_dues_id'] = $paydue_id[3];
$neworder['amount'] = $paydue_data['payment_due_amount'];
$neworder['order_status'] = "completed";
if ($inputs['paymentTypeRadioOldCustomer4'] == 'cash') {
$neworder['payment_mode'] = 'cash';
} else {
if ($inputs['paymentTypeRadioOldCustomer4'] == 'cheque') {
$neworder['payment_mode'] = 'cheque';
$neworder['bank_name'] = $inputs['bankName4'];
$neworder['cheque_number'] = $inputs['chequeNumber4'];
} else {
if ($inputs['paymentTypeRadioOldCustomer4'] == 'card') {
$neworder['payment_mode'] = 'card';
$neworder['card_type'] = $inputs['cardType4'];
$neworder['card_last_digit'] = $inputs['card4digits4'];
$neworder['bank_name'] = $inputs['cardBankName4'];
$neworder['receipt_number'] = $inputs['cardRecieptNumber4'];
}
}
}
$neworder['created_at'] = $paydue_data['created_at'];
$neworder->created_by = Session::get('userId');
$neworder->save();
}
if (isset($inputs['membershipType'])) {
$membershipInputs['customer_id'] = $inputs['customerId'];
$membershipInputs['membership_type_id'] = $inputs['membershipType'];
CustomerMembership::addMembership($membershipInputs);
}
$student = Students::with('Customers', 'StudentClasses')->where('id', '=', $enrollment->student_id)->get();
$class = Classes::where('id', '=', $enrollment->class_id)->get();
$CustomerObject = Customers::find($inputs['customerId']);
$CustomerObject->stage = "ENROLLED";
$CustomerObject->save();
$customer = array();
$customer['customerName'] = $student['0']->Customers->customer_name;
$customer['customerEmail'] = $student['0']->Customers->customer_email;
$customer['kidName'] = $student['0']->student_name;
$customer['className'] = $class['0']->class_name;
$commentsInput['customerId'] = $inputs['customerId'];
$commentsInput['commentText'] = Config::get('constants.ENROLLED') . ' for ' . $class['0']->class_name;
$commentsInput['commentType'] = 'FOLLOW_UP';
$commentsInput['reminderDate'] = null;
Comments::addComments($commentsInput);
if (isset($inputs['emailOption']) && $inputs['emailOption'] == 'yes') {
$orders = Orders::with('Customers', 'Students', 'StudentClasses')->where('id', '=', $orderCreated->id)->get();
$orders = $orders['0'];
$paymentDues = PaymentDues::where('id', '=', $orders->payment_dues_id)->get();
$batchDetails = Batches::where('id', '=', $orders->StudentClasses->batch_id)->get();
$class = Classes::where('id', '=', $orders->StudentClasses->class_id)->where('franchisee_id', '=', Session::get('franchiseId'))->first();
$customerMembership = CustomerMembership::getCustomerMembership($orders->customer_id);
$class = Classes::where('id', '=', $inputs['eligibleClassesCbx'])->where('franchisee_id', '=', Session::get('franchiseId'))->first();
$batch = Batches::where('id', '=', $inputs['batchCbx'])->first();
$orderDetailsTomail['orders'] = $orders;
$orderDetailsTomail['customers'] = $customer;
$orderDetailsTomail['paymentDues'] = $paymentDues;
$orderDetailsTomail['customerMembership'] = $customerMembership;
$orderDetailsTomail['class'] = $class;
$orderDetailsTomail['batchDetails'] = $batchDetails;
$orderDetailsTomail['studentbatch']['start_date'] = date('Y-m-d', strtotime($inputs['enrollmentStartDate']));
$orderDetailsTomail['studentbatch']['end_date'] = date('Y-m-d', strtotime($inputs['enrollmentEndDate']));
$orderDetailsTomail['customers']['customerMembership'] = CustomerMembership::getCustomerMembership($orders->customer_id);
Mail::send('emails.account.enrollment', $orderDetailsTomail, function ($msg) use($orderDetailsTomail) {
$msg->from(Config::get('constants.EMAIL_ID'), Config::get('constants.EMAIL_NAME'));
$msg->to($orderDetailsTomail['customers']['customerEmail'], $orderDetailsTomail['customers']['customerName'])->subject('The Little Gym - Kids Enrollment Successful');
});
}
if (isset($inputs['invoicePrintOption']) && $inputs['invoicePrintOption'] == 'yes') {
$printUrl = url() . '/orders/print/' . Crypt::encrypt($orderCreated->id);
} else {
$printUrl = "";
}
//header('Access-Control-Allow-Origin: *');
if ($enrollment) {
return Response::json(array("status" => "success", "printUrl" => $printUrl));
} else {
return Response::json(array("status" => "failed"));
}
}