示例#1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //dd(Request::file());
     //
     $pkm = new PkmModel();
     //dd(base_path());
     //TODO validasi
     $validator = Validator::make(Input::all(), ['title' => 'required', 'leader' => 'required', 'year' => 'required', 'status' => 'required', 'category' => 'required', 'file' => 'required|mimes:pdf']);
     if ($validator->fails()) {
         return redirect('/pkm/add')->withErrors($validator)->withInput();
     }
     $pkm->title = Input::get('title');
     $pkm->leader = Input::get('leader');
     $pkm->year = Input::get('year');
     $pkm->status = Input::get('status');
     $pkm->category = Input::get('category');
     $userDb = userModel::where('username', Session::get('user')->username)->first();
     $pkm->uploader = $userDb->id;
     $pkm->save();
     $file = Request::file('file');
     if ($file->move(base_path() . '/public/upload/pkm', $pkm->id . '.' . $file->getClientOriginalExtension())) {
     }
 }
示例#2
0
 public function login()
 {
     SSO::authenticate();
     if (SSO::check()) {
         $user = SSO::getUser();
         //TODO cek udah ada di database apa belum
         $userDb = userModel::where('username', $user->username)->first();
         if ($userDb) {
             $user->role = $userDb->role;
             Session::put('user', $user);
             return redirect('pkm/add');
         } else {
             Session::put('user', $user);
         }
         return redirect('auth/newUser');
     }
 }