本文整理汇总了PHP中Courses::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Courses::all方法的具体用法?PHP Courses::all怎么用?PHP Courses::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Courses
的用法示例。
在下文中一共展示了Courses::all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveItem
//.........这里部分代码省略.........
if ($cat_id == 2) {
//通知编辑
$item->title = $title;
$item->content = $content;
$item->save();
return Redirect::to(URL::to('/notice-detail', [$item_id]));
} else {
if ($cat_id == 3) {
//课程编辑
$item->course_name = $course_name;
$item->course_info = $course_info;
$item->teacher_address = $teacher_address;
$item->teacher_mail = $teacher_mail;
$item->TA_name = $TA_name;
$item->TA_address = $TA_address;
$item->TA_mail = $TA_mail;
$item->save();
$course_notices_add_count = Input::get('course_notice_add_count');
if ($course_notices_add_count) {
//增加新的通知
for ($i = 1; $i <= $course_notices_add_count; $i++) {
$add_or_not = Input::get('course_notice_add_or_not' . $i);
if (!$add_or_not) {
$notice = new Comments();
$notice->course_id = $item_id;
$notice->comment = Input::get('course_notice_add_content' . $i);
$notice->created_at = date("Y-m-d H:i:s");
$notice->updated_at = date("Y-m-d H:i:s");
$notice->save();
}
}
}
$homework_add_count = Input::get('homework_add_count');
if ($homework_add_count) {
//当添加了新的作业,将其添加到homework数据库中
for ($i = 1; $i <= $homework_add_count; $i++) {
$add_or_not = Input::get('homework_add_or_not' . $i);
if (!$add_or_not) {
$homework = new Homework();
$homework->course_id = $item_id;
$homework->homework_item = Input::get('homework_add_item' . $i);
$homework->submit_deadline = Input::get('homework_add_submit_time' . $i);
$homework->deliver_deadline = Input::get('homework_add_deliver_time' . $i);
$homework->created_at = date("Y-m-d H:i:s");
$homework->updated_at = date("Y-m-d H:i:s");
$homework->save();
}
}
}
$courseware_add_count = Input::get('courseware_add_count');
if ($courseware_add_count) {
//当添加了新的课件,将其添加到courseware表中
for ($i = 1; $i <= $courseware_add_count; $i++) {
$courseware = new Courseware();
$courseware->course_id = $item_id;
$courseware->label = Input::get('courseware_add_label' . $i);
//先将课件上传到数据库中
$file_source = 'courseware_add_source' . $i;
$courseware->source = HomeController::upload_course($item_id, $file_source);
$courseware->created_at = date("Y-m-d H:i:s");
$courseware->updated_at = date("Y-m-d H:i:s");
$courseware->save();
}
}
return Redirect::to(URL::to('/course', [$item_id]));
}
}
}
}
} else {
//对已有条目进行更新
if ($cat_id == 0) {
//新闻条目
News::insert(['title' => $title, 'abstract' => $abstract, 'content' => $content]);
$item = News::all()->last();
return Redirect::to(URL::to('/news-detail', [$item->id]));
} else {
if ($cat_id == 1) {
//项目条目
Researches::insert(['title' => $title, 'abstract' => $abstract, 'content' => $content, 'begin_time' => $begin_time, 'end_time' => $end_time]);
$item = Researches::all()->last();
return Redirect::to(URL::to('/research-detail', [$item->id]));
} else {
if ($cat_id == 2) {
//通知编辑
Notices::insert(['title' => $title, 'content' => $content]);
$item = Notices::all()->last();
return Redirect::to(URL::to('/notice-detail', [$item->id]));
} else {
if ($cat_id == 3) {
Courses::insert(['course_name' => $course_name, 'course_info' => $course_info, 'teacher_address' => $teacher_address, 'TA_name' => $TA_name, 'TA_address' => $TA_address]);
$item = Courses::all()->last();
return Redirect::to(URL::to('/course', [$item->id]));
}
}
}
}
}
//return View::make('/news-detail',[$item_id]);
}