本文整理汇总了PHP中Classes::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Classes::create方法的具体用法?PHP Classes::create怎么用?PHP Classes::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Classes
的用法示例。
在下文中一共展示了Classes::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDummyClass
/**
* Function that creates dummy class.
*/
protected function createDummyClass($id)
{
return Classes::create(array('classlecturer' => 1, 'classmodule' => $id, 'classlimit' => 25));
}
示例2: function
$message = '更新《' . $data['year_name'] . '》完成';
} else {
$message = '資料寫入錯誤';
}
return Redirect::to('/class_year/view_year/' . $yearId)->with('message', $message);
}
});
// 執行新增班級
Route::post('/add_classes/{yearId}', function ($yearId) {
$validator = FormValidator::classes(Input::all());
if ($validator->fails()) {
return Redirect::to('/class_year/view_year/' . $yearId)->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查');
} else {
$data = Input::all();
$data['year_id'] = $yearId;
if (Classes::create($data)) {
$message = '新增班級《' . $data['classes_name'] . '》完成';
} else {
$message = '資料寫入錯誤';
}
Classes::syncTeacher();
return Redirect::to('/class_year/view_year/' . $yearId)->with('message', $message);
}
});
// 執行編輯班級
Route::post('/update_classes/{classesId}/{yearId}', function ($classesId, $yearId) {
$validator = FormValidator::classes(Input::all());
if ($validator->fails()) {
return Redirect::to('/class_year/view_year/' . $yearId)->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查');
} else {
$data = Input::all();
示例3: postElectiveNew
public function postElectiveNew()
{
$inputData = Input::get('elecData');
parse_str($inputData, $formFields);
$moduleData = array('classlecturer' => $formFields['classlecturer'], 'classmodule' => $formFields['classmodule'], 'classlimit' => $formFields['classlimit']);
Validator::extend('ranked', function ($attribute, $value, $parameters) {
// This is the correct way to do this.
$coord = User::where('name', $value)->first();
if ($coord && $coord->rank < 1) {
return false;
}
return true;
});
Validator::extend('indep', function ($attribute, $value, $parameters) {
// This is the correct way to do this.
$mod = Modules::find($value);
if ($mod && $mod->departmentid !== Auth::user()->department) {
return false;
}
return true;
});
$rules = array('classmodule' => 'required|exists:modules,mid|indep', 'classlecturer' => 'required|exists:users,name|ranked', 'classlimit' => 'required|integer|between:5,30');
$messages = ['ranked' => "This user can't coordinate this class.", 'indep' => "This module is not in your department."];
$validator = Validator::make($moduleData, $rules, $messages);
if ($validator->fails()) {
return Response::json(array('fail' => true, 'errors' => $validator->getMessageBag()->toArray()));
} else {
$moduleData['classlecturer'] = User::where('name', $moduleData['classlecturer'])->first()->id;
if (Classes::create($moduleData)) {
Session::flash('global', 'You have created an elective.');
//return success message
return Response::json(array('success' => true, 'mName' => Modules::find($moduleData['classmodule'])->mshorttitle));
}
}
}