Example #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $this->layout = '//layouts/column1';
     $model = new Ekstra();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Ekstra'])) {
         $model->attributes = $_POST['Ekstra'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id_ekstra));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('nama' => 'required');
     $pesan = array('nama.required' => 'Nama Ekstrakurikuler harus diisi');
     $validasi = Validator::make(Input::all(), $rules, $pesan);
     if ($validasi->fails()) {
         return Redirect::back()->withErrors($validasi)->withInput();
     } else {
         $ekstra = new Ekstra();
         $ekstra->nm_ekstra = Input::get('nama');
         $ekstra->nip_pengampu = Input::get('nip');
         $ekstra->keterangan = Input::get('keterangan');
         if (Input::hasFile('logo')) {
             $file = Input::file('logo');
             $filename = str_random(5) . '-' . $file->getClientOriginalName();
             $destinationPath = 'uploads/ekstra/';
             $file->move($destinationPath, $filename);
             $ekstra->logo_ekstra = $filename;
         }
         $ekstra->save();
         Session::flash('pesan', "<div class='alert alert-success'>\n\t\t\tData Ektrakurikuler berhasil disimpan</div>");
         return Redirect::to('admin/ekstrakurikuler');
     }
 }