public function run() { Eloquent::unguard(); DB::table('years')->delete(); Year::create(['id' => 1, 'year' => 2015, 'nombre_colegio' => 'LICEO ADVENTISTA LIBERTAD', 'abrev_colegio' => 'LAL', 'nota_minima_aceptada' => 70, 'resolucion' => 'RESOLUCIÓN 2563 DE 2014', 'actual' => true, 'alumnos_can_see_notas' => true]); $this->command->info("Año 2014 y 2015 agregados."); /* OTRA FORMA ******************************************************************** // Abrimos el archivo donde tengo los municipios restantes de Colombia // recorremos los registros y los ingresamos a la base de datos $this->command->info("Leemos los csv para las cuidades colombianas faltantes..."); $csv = dirname(__FILE__) .'/SqlTables/CuidadesDeColombia.csv'; $file_handle = fopen($csv, "r"); while (!feof($file_handle)) { $line = fgetcsv($file_handle); if (empty($line)) { continue; // skip blank lines } $c = array(); $c['nombre'] = $line[0]; $c['pais_codigo'] = $line[1]; $c['distrito'] = $line[2]; $c['poblacion'] = $line[3]; //$this->command->info( implode(",", $c)); DB::table('ciudads')->insert($c); } fclose($file_handle); */ }
public function post_add() { $input = Input::get(); $rules = array('year' => 'required|numeric', 'name' => 'required', 'alias' => 'required|max:128'); $validation = Validator::make($input, $rules); if ($validation->passes()) { $year = Year::create(Input::get()); return Redirect::to('rms/years')->with('success', 'Successfully Added New Year: ' . $year->year . ' - ' . $year->name); } else { return Redirect::to('rms/years/add/')->withErrors($validation)->withInput(); } }
</select> </td> </tr> <tr> <td colspan="2"><button id="new" name="new" class="btn btn-primary" type="button" onclick="createYear()">Create</button></td> </tr> </table> </form> <div id="loading" class="alert alert-info" role="alert" style="display: none"> </div> <?php } else { if ($do == 'add') { extract($_POST); Year::create($year, $era); if ($era == 1) { $dis = $year . ' UFY'; } else { $dis = $year . ' IRY'; } Event::addEvent('Year ' . $dis . ' has been added.', $_SESSION['user'], 1); } } } else { if ($action == 'current') { $year = new Year($_GET['id']); $year->makeCurrent(); Event::addEvent('Year ' . $year->getFullYear() . ' is now the current year.', $_SESSION['user'], 2); ?> <script>
*/ Route::group(array('prefix' => 'class_year', 'before' => 'auth'), function () { // 讀取年級列表 $GLOBALS['yearList'] = Year::orderBy('year_name')->get(); // 顯示年級列表、年級新增表單 Route::get('/', function () { return View::make('class_year')->with(array('yearList' => $GLOBALS['yearList'], 'year' => NULL)); }); // 執行新增年級 Route::post('/add_year', function () { $validator = FormValidator::year(Input::all()); if ($validator->fails()) { return Redirect::to('/class_year')->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查'); } else { $data = Input::all(); if (Year::create($data)) { $message = '新增年級《' . $data['year_name'] . '》完成'; } else { $message = '資料寫入錯誤'; } return Redirect::to('/class_year')->with('message', $message); } }); // 顯示年級編輯標單、班級列表、新增班級表單 Route::get('/view_year/{yearId}', function ($yearId) { $viewData['year'] = Year::find($yearId); $viewData['classes'] = Year::find($yearId)->classes()->orderBy('classes_name')->get(); $viewData['yearList'] = $GLOBALS['yearList']; return View::make('class_year')->with($viewData); }); // 執行編輯年級