Ejemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $rules = ['parent' => 'required', 'material_img' => 'required|mimes:jpeg,png', 'pdf_exam' => 'required|mimes:pdf', 'pdf_exam_corr' => 'required|mimes:pdf'];
     $validator = Validator::make($request->all(), $rules);
     $validator->SetAttributeNames(['parent' => trans('author.choicematerial'), 'material_img' => trans('author.materialimg'), 'pdf_exam' => trans('author.pdf_exam'), 'pdf_exam_corr' => trans('author.pdf_exam_corr')]);
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator);
     } else {
         if ($request->hasFile('material_img') && $request->hasFile('pdf_exam') && $request->hasFile('pdf_exam_corr')) {
             $imgs = $request->file('material_img');
             $pdfexam = $request->file('pdf_exam');
             $pdfexamcorr = $request->file('pdf_exam_corr');
             if ($imgs->isValid() && $pdfexam->isValid() && $pdfexamcorr->isValid()) {
                 $exam = new Exam();
                 $imgsext = $imgs->getClientOriginalExtension();
                 $pdfexamext = $pdfexam->getClientOriginalExtension();
                 $pdfexamcorrext = $pdfexamcorr->getClientOriginalExtension();
                 $imgsname = time() . '.' . $imgsext;
                 $pdfexamname = 2 * time() . '.' . $pdfexamext;
                 $pdfexamcorrname = 3 * time() . '.' . $pdfexamcorrext;
                 $exam->image = $imgsname;
                 $exam->exam_pdf = $pdfexamname;
                 $exam->exam_corr_pdf = $pdfexamcorrname;
                 $exam->categories_id = $request->input('parent');
                 $exam->save();
                 session()->flash('success', trans('author.success_add'));
                 $uploadimgs = $imgs->move(base_path() . '/resources/views/dirassa/asset/images', $imgsname);
                 $uploadpdfexam = $pdfexam->move(base_path() . '/resources/views/dirassa/asset/pdf', $pdfexamname);
                 $uploadpdfexamcorr = $pdfexamcorr->move(base_path() . '/resources/views/dirassa/asset/pdf', $pdfexamcorrname);
                 return redirect()->back();
             }
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\ExamFormRequest $request)
 {
     //dd($request);
     $input = $request->all();
     $exam = new Exam();
     $exam->title = $input['title'];
     $exam->exam_description = $input['exam_description'];
     $exam->exam_date = $input['exam_date'];
     $exam->course_id = $input['course_id'];
     $exam->exam_mark = $input['exam_mark'];
     //$exam->admin_id=$input['admin_id'];//user id
     $exam->save();
     return redirect('/exam')->with('status', 'Exam inserted successfully');
 }
Ejemplo n.º 3
0
 public function postAddExam()
 {
     //Moin
     //Exam post Function for admin
     $examname = Input::get('examname');
     $date = Input::get('date');
     $note = Input::get('note');
     //return $examname.'/'.$date.'/'.$note;
     $save = new Exam();
     $save->institute_code = Auth::user()->institute_id;
     $save->exam_id = 'exam' . mt_rand('1', '9999');
     $save->exam_name = $examname;
     $save->exam_date = $date;
     $save->note = $note;
     $save->save();
     Session::flash('data', 'Update successfully added !');
     return Redirect::to('/admin/add/exam');
 }