Exemplo n.º 1
0
 /**
  * @POST("/purchase", as="purchase.store")
  * @param Purchase $purchase
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(Purchase $purchase, Request $request)
 {
     $data = $request->all();
     if ((int) $data['amount'] <= 0) {
         return redirect()->route('profile.index')->with('message', 'Некорректная сумма вклада!');
     }
     $type1 = TypePurchase::where('id', 1)->first();
     $type2 = TypePurchase::where('id', 2)->first();
     $type3 = TypePurchase::where('id', 3)->first();
     $user = User::where('id', $request->input('user_id'))->first();
     $course = Course::where('currency_id', $request->input('currency_id'))->first();
     $data['course'] = $course->course_purchase;
     if ($request->input('status_trust') === 'true') {
         $data['status_trust'] = 1;
         $purchase->fill($data);
         $purchase->type()->associate($type2);
         $purchase->user()->associate($user);
         $purchase->course()->associate($course);
         $purchase->save();
     } elseif (!$request->input('total')) {
         $data['total'] = $request->input('amount');
         $purchase->fill($data);
         $purchase->type()->associate($type3);
         $purchase->user()->associate($user);
         $purchase->course()->associate($course);
         $purchase->save();
     } else {
         $purchase->fill($data);
         $purchase->type()->associate($type1);
         $purchase->user()->associate($user);
         $purchase->course()->associate($course);
         $purchase->save();
     }
     return redirect()->route('profile.index')->with('message', 'Заявка сделана! Свои оперции Вы можете
     посмотреть в разделе "Мои операции"');
 }
 public function universityCourses($uni_id)
 {
     $courses = Course::where('university_id', $uni_id)->get()->toArray();
     if ($courses) {
         $message = 'Success';
         return Response()->json(ResponseManager::getResult($courses, 10, $message));
     } else {
         $message = 'No Course added';
         return Response()->json(ResponseManager::getError('', 10, $message));
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $delete = Course::where('id', $id)->delete();
     if ($delete) {
         $message = 'Detele successfully';
         return Response()->json(ResponseManager::getResult($delete, 10, $message));
     } else {
         $message = 'Error while deleting';
         return Response()->json(ResponseManager::getError('', 10, $message));
     }
 }
 /**
  * Search in courses.
  *
  * @param  string  $search
  * @return Response
  */
 public function search($id, $search)
 {
     $courses = Course::where('name', 'like', '%' . $search . '%')->where('college_id', $id)->take(6)->get();
     return response()->json($courses);
 }
Exemplo n.º 5
0
 /**
  * Show all course only taught by this lecturer on current semester
  * @return $this
  */
 public function viewCourseByLecturer()
 {
     //get current user
     $user = Auth::user();
     //get the mapping for lecturer
     $kode_dosen = $user->lecturer->Kode_Dosen;
     $id_semester = Kalender::getRunningSemester()->id;
     $courses = Course::where('Kode_Dosen', $kode_dosen)->where('id_semester', $id_semester)->get();
     return view('lecturers.showcourse')->with('Courses', $courses);
 }
Exemplo n.º 6
0
 protected function checkSectionId($validator)
 {
     $seksi = $validator->getData()['kode_seksi'];
     $id_semester = Kalender::getRunningSemester()->id;
     $instance = Course::where('seksi', $seksi)->where('id_semester', $id_semester)->get();
     if (count($instance) == 0) {
         return true;
     }
     return false;
     //the precondition for being add, section id must not exist for current user or has been registered
 }