/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('faculty')->delete();
     $faculties = array(['faculty_name' => 'Faculty of engineering'], ['faculty_name' => 'Faculty of computer science and IT']);
     foreach ($faculties as $faculty) {
         Faculty::create($faculty);
     }
 }
Beispiel #2
0
                    $mail->setHTMLBody("Hi {$name},<br/>You have successfully registered for C-SCAN 2016. Your registration ID is " . $regid . ". The confirmation regarding the same will be done via email on or before 1st February.<br/>For more details and updates, please visit our <a href='http://www.cscan.org.in'>website</a>.<br/><br/>Thank you.<br/><br/>Yours Sincerely,<br/>Organising Team,<br/>C-SCAN 2016.");
                    $mailer->send($mail);
                } else {
                    $error = ERROR_DB;
                }
            } else {
                $error = ERROR_INVALID;
            }
        } else {
            if ($_POST['type'] == "faculty") {
                $rules = array('college' => 'required|integer', 'name' => 'required', 'email' => 'required|email', 'phone' => 'required|numeric|digits_between:10,15', 'designation' => 'required', 'interest' => 'required', 'gender' => 'required', 'food' => 'required');
                $validator = $factory->make($_POST, $rules, $messages);
                if ($validator->passes()) {
                    $num = Faculty::where('college', $_POST['college'])->count();
                    $_POST['regid'] = $num + 1;
                    if ($v = Faculty::create($_POST)) {
                        $regid = $v->colg->abbr . "F" . str_pad($_POST['regid'], 3, '0', STR_PAD_LEFT);
                        $name = $_POST['name'];
                        $mail->setHTMLBody("Hi {$name},<br/>You have successfully registered for C-SCAN 2016. Your registration id is " . $regid . ". The confirmation regarding the same will be done via email on or before 1st February.<br/>For more details and updates, please visit our <a href='http://www.cscan.org.in'>website</a>.<br/><br/>Thank you.<br/>Yours Sincerely,<br/>Organising Team,<br/>C-SCAN 2016.");
                        $mailer->send($mail);
                    } else {
                        $error = ERROR_DB;
                    }
                } else {
                    $error = ERROR_INVALID;
                }
            }
        }
    }
}
include_once './header.php';
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(FacultyRequest $request)
 {
     Faculty::create($request->all());
     Flash::success('The Faculty has been created.');
     return redirect()->route('faculty.index');
 }
Beispiel #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param FacultiesRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(FacultiesRequest $request)
 {
     Faculty::create($request->all());
     \Flash::success('Faculteit toegevoegd');
     return redirect('admin/faculties');
 }
Beispiel #5
0
 /**
  * Store a csv created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function import(Request $request)
 {
     if ($request->file('csv-file')->isValid()) {
         $csv_file = $request->file('csv-file');
         if ("text/csv" == $csv_file->getClientMimeType()) {
             $dest_path = storage_path('temp');
             $file_name = time() . '_' . str_replace(" ", "_", $csv_file->getClientOriginalName());
             $csv_file->move($dest_path, $file_name);
             $fname = $dest_path . '/' . $file_name;
             $file = fopen($fname, "r");
             $flash_message = [];
             $flash_error = 0;
             while (!feof($file)) {
                 $tmp_data = fgetcsv($file);
                 $item['department_id'] = !empty($tmp_data[0]) ? $tmp_data[0] : '';
                 $department = Department::where('code', '=', $item['department_id'])->first();
                 if ($department) {
                     $item['department_id'] = $department->id;
                 }
                 $item['last_name'] = !empty($tmp_data[1]) ? $tmp_data[1] : '';
                 $item['first_name'] = !empty($tmp_data[2]) ? $tmp_data[2] : '';
                 $item['max_units'] = !empty($tmp_data[3]) ? $tmp_data[3] : '';
                 $item['type'] = !empty($tmp_data[4]) ? strtolower($tmp_data[4]) : '';
                 $v = Validator::make($item, ['department_id' => 'required|integer|min:1', 'last_name' => 'required|max:254', 'first_name' => 'required|max:254', 'max_units' => 'integer|max:120', 'type' => 'required|in:full-time,part-time']);
                 if (!$v->fails()) {
                     Faculty::create($item);
                     $flash_message['success'][] = $item['last_name'] . ', ' . $item['first_name'];
                 } else {
                     $flash_error++;
                     $flash_message['error'] = $flash_error;
                 }
             }
             \Session::flash('flash_message', $flash_message);
             fclose($file);
             chmod($fname, 0777);
             unlink($fname);
         }
     }
     return redirect('/faculties');
 }