本文整理匯總了PHP中HomeController::delete_file方法的典型用法代碼示例。如果您正苦於以下問題:PHP HomeController::delete_file方法的具體用法?PHP HomeController::delete_file怎麽用?PHP HomeController::delete_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HomeController
的用法示例。
在下文中一共展示了HomeController::delete_file方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveItem
public function saveItem()
{
$cat_id = Input::get('cat_id');
$item_id = Input::get('id');
//獲取表單
if ($cat_id == 0) {
//新聞編輯
$title = Input::get('title');
$content = Input::get('content');
$abstract = Input::get('abstract');
$item = News::find($item_id);
} else {
if ($cat_id == 1) {
//項目編輯
$title = Input::get('title');
$content = Input::get('content');
$abstract = Input::get('abstract');
$begin_time = Input::get('begin_time');
$end_time = Input::get('end_time');
$item = Researches::find($item_id);
} else {
if ($cat_id == 2) {
//通知編輯
//
$title = Input::get('title');
$content = Input::get('content');
$item = Notices::find($item_id);
} else {
if ($cat_id == 3) {
//課程編輯
$course_name = Input::get('course_name');
$course_info = Input::get('course_info');
$teacher_address = Input::get('teacher_address');
$teacher_mail = Input::get('teacher_mail');
$TA_name = Input::get('TA_name');
$TA_address = Input::get('TA_address');
$TA_mail = Input::get('TA_mail');
$item = Courses::find($item_id);
$homeworks = Courses::find($item_id)->homework;
$coursewares = Courses::find($item_id)->courseware;
$course_notices = Courses::find($item_id)->comments;
foreach ($course_notices as $notice) {
$update_notice = Comments::find($notice->id);
$update_notice->comment = Input::get('course_notice_content' . $notice->id);
$update_notice->updated_at = date("Y-m-d H:i:s");
$update_notice->save();
}
foreach ($homeworks as $homework) {
//對已有項進行編輯
$delete_or_not = Input::get('homework_delete' . $homework->id);
if ($delete_or_not) {
//如果標記為刪除則將已有作業進行刪除
$delete_item = Homework::find($homework->id);
$delete_item->delete();
} else {
$update_item = Homework::find($homework->id);
$update_item->homework_item = Input::get('homework_label' . $homework->id);
$update_item->submit_deadline = Input::get('homework_submit_time' . $homework->id);
$update_item->deliver_deadline = Input::get('homework_deliver_time' . $homework->id);
$update_item->updated_at = date("Y-m-d H:i:s");
$update_item->save();
}
}
foreach ($coursewares as $courseware) {
$update_item = Courseware::find($courseware->id);
$update_item->label = Input::get('courseware_label' . $courseware->id);
$update_file_source = 'courseware_ppt' . $courseware->id;
$new_source = HomeController::upload_course($item_id, $update_file_source);
if ($new_source != "") {
//跟新源的同時將舊的課件刪除
HomeController::delete_file($update_item->source);
$update_item->source = $new_source;
} else {
}
$update_item->updated_at = date("Y-m-d H:i:s");
$update_item->save();
}
}
}
}
}
//保存數據
if ($item) {
//表中已經存在該條目
if ($cat_id == 0) {
//新聞編輯
$item->title = $title;
$item->content = $content;
$item->abstract = $abstract;
$item->save();
return Redirect::to(URL::to('/news-detail', [$item_id]));
} else {
if ($cat_id == 1) {
//項目編輯
$item->title = $title;
$item->content = $content;
$item->abstract = $abstract;
$item->begin_time = $begin_time;
$item->end_time = $end_time;
$item->save();
//.........這裏部分代碼省略.........