Ejemplo n.º 1
0
 public function removeMember(Request $request)
 {
     $classroom = Classroom::findOrFail($request->classroom_id);
     $classroom->students()->detach($request->user_id);
     \Flash::success('User berhasil dihapus dari kelas.');
     return redirect()->back();
 }
Ejemplo n.º 2
0
 public function index()
 {
     $users = User::orderBy('created_at', 'DESC')->paginate(5);
     $majors = Major::orderBy('created_at', 'DESC')->paginate(5);
     $subjects = Subject::orderBy('created_at', 'DESC')->paginate(5);
     $classrooms = Classroom::orderBy('created_at', 'DESC')->paginate(5);
     $announcements = Announcement::orderBy('created_at', 'DESC')->paginate(5);
     return view('admin.home.home', compact('users', 'majors', 'subjects', 'classrooms', 'announcements'));
 }
Ejemplo n.º 3
0
 public function compose(View $view)
 {
     $data = [];
     $data['profile'] = Auth::user();
     $data['majors'] = Major::all();
     $data['subjects'] = Subject::all();
     $data['classrooms'] = Classroom::all();
     $view->with('lms', $data);
 }
Ejemplo n.º 4
0
 public function compose(View $view)
 {
     $joined_class = Auth::user()->joinedClassrooms;
     $data = [];
     $data['profile'] = Auth::user();
     $data['classrooms'] = Classroom::find($joined_class);
     $data['assignments'] = $this->classAssignment($joined_class);
     $data['online'] = User::onlineusers()->limit(8)->get();
     $view->with('lms', $data);
 }
Ejemplo n.º 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Classroom::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['class_id' => $this->class_id, 'teacher_id' => $this->teacher_id, 'created_dt' => $this->created_dt]);
     $query->andFilterWhere(['like', 'course_id', $this->course_id])->andFilterWhere(['like', 'opendate', $this->opendate])->andFilterWhere(['like', 'recive', $this->recive])->andFilterWhere(['like', 'place', $this->place])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Ejemplo n.º 6
0
 public function downloadSubmission($classroom_id, $assignment_id)
 {
     $classroom = Classroom::with('assignments')->findOrFail($classroom_id);
     $assignment = $classroom->assignments()->where('assignment_id', $assignment_id)->first();
     $users = $assignment->submissions;
     $data = $users->map(function ($user, $index) {
         return ['No' => $index + 1, 'Nama Siswa' => $user->fullname, 'Subject' => $user->pivot->title, 'Isi' => $user->pivot->content, 'Url File' => route('classrooms.download', $user->pivot->file)];
     });
     return Excel::create($assignment->title, function ($excel) use($data) {
         $excel->sheet('Sheet 1', function ($sheet) use($data) {
             $sheet->fromArray($data);
         });
     })->download('xls');
 }
Ejemplo n.º 7
0
 /**
  * Finds the Classroom model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Classroom the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Classroom::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 8
0
 public function getClassroom()
 {
     return $this->hasMany(Classroom::className(), ['course_id' => 'course_id']);
 }