/** * Store a newly created resource in storage. * * @return Response */ public function store(SubjectRequest $request) { $data = $request->all(); unset($data['Id']); $subject = new Subject(); $subject->fromArray($data); $subject->save(); flash()->success("ADDED"); session(['attribute' => \Lang::get('general.SUBJECT')]); return redirect($this->main_page); }
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')); }
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); }
/** * Register any application services. * * @return void */ public function register() { // Bind our eloquent subject collection to the interface $this->app->singleton('App\\Contracts\\SubjectsCollectionInterface', function () { return Subject::all(); }); // Use speedtest tester for tests $this->app->bind('App\\Contracts\\TesterInterface', 'App\\Services\\SpeedtestTester'); }
/** * Execute the console command. * * @return mixed */ public function handle() { if (Config::get('app.worker_id') != Config::get('app.generator_worker_id') && !App::isLocal()) { return; } $this->line('Generating status page...'); $viewVariables = ['subjectGroups' => Subject::all()->groupBy('group'), 'subjects' => Subject::all()]; Storage::disk('local')->put('status.html', view('index', $viewVariables)); $this->line('Finished'); }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { $subject = Subject::findOne(['id' => $this->subject_id]); $this->section = $subject->section; $question = new Question(); $this->questions_ids = $question->getSubjectQuestionsIds($this->subject_id); return true; } return false; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Subject::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(['id' => $this->id]); $query->andFilterWhere(['like', 'subject_name', $this->subject_name]); return $dataProvider; }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { $cur_subject = Subject::findOne(['id' => $this->subject_id]); $this->section = $cur_subject->section; $question = new Question(); $subjects = Subject::find()->where(['section' => $cur_subject->section, 'type' => 1])->all(); $q_ids = ''; foreach ($subjects as $subject) { $q_ids .= $question->getSubjectQuestionsIds($subject->id) . ','; } $q_ids .= $question->getSubjectQuestionsIds($cur_subject->id); $this->questions_ids = $q_ids; return true; } return false; }
/** * @return \yii\db\ActiveQuery */ public function getClssSubj() { return $this->hasOne(Subject::className(), ['subj_id' => 'clss_subj_id']); }
/** * Filter the query by a related \App\Models\Subject object * * @param \App\Models\Subject|ObjectCollection $subject The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @throws \Propel\Runtime\Exception\PropelException * * @return ChildEngagementQuery The current query, for fluid interface */ public function filterBySubject($subject, $comparison = null) { if ($subject instanceof \App\Models\Subject) { return $this->addUsingAlias(EngagementTableMap::COL_SUBJECT_ID, $subject->getId(), $comparison); } elseif ($subject instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(EngagementTableMap::COL_SUBJECT_ID, $subject->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterBySubject() only accepts arguments of type \\App\\Models\\Subject or Collection'); } }
use yii\helpers\Html; use yii\grid\GridView; use app\models\Subject; use app\models\SubjectTest; use app\models\EntTest; /* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Мои результаты'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="user-score-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'test_id', ['attribute' => 'test_type', 'value' => function ($model) { if ($model->test_type == 0) { $subject = SubjectTest::findOne(['id' => $model->test_id]); return 'Тест по предмету ' . Subject::findOne(['id' => $subject->subject_id])->title; } else { $test = EntTest::findOne(['id' => $model->test_id]); return 'Ент тест п/в: ' . Subject::findOne(['id' => $test->subject_id])->title; } }], 'created_at:datetime', 'updated_at:datetime', 'score']]); ?> </div>
public function actionRemove() { $subjects = Subject::find()->all(); foreach ($subjects as $subject) { for ($i = 1; $i <= 25; $i++) { if ($i <= 15) { $question = Question::findOne(['description' => 'Легкий вопрос ' . $i]); } elseif ($i > 15 && $i <= 25) { $question = Question::findOne(['description' => 'Средний вопрос ' . $i]); $question->description = 'Средний вопрос ' . $i; $question->level = 1; } else { $question = Question::findOne(['description' => 'Сложный вопрос ' . $i]); } $question->delete(); } } return 111; }
/** * Show the form for editing the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function edit($society, $id) { if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) { $data['society'] = $society; $data['blog'] = Blog::find($id); $data['chosensoc'] = explode(',', $data['blog']->societies); if (count($data['blog']->subject)) { foreach ($data['blog']->subject as $subj) { $data['blogsubjects'][] = $subj->id; } } else { $data['blogsubjects'][0] = 0; } $data['author'] = Individual::where('slug', '<>', '')->orderBy('surname')->orderBy('firstname')->get(); $data['subjects'] = Subject::orderBy('subject')->get(); $allsoc = Permission::where('user_id', '=', Auth::user()->id)->get(); foreach ($allsoc as $asoc) { $data['societies'][$asoc->society_id] = $asoc->society->society; } return view('blogs.edit', $data); } else { return View::make("shared.unauthorised"); } }
/** * @return \yii\db\ActiveQuery */ public function getId0() { return $this->hasOne(Subject::className(), ['id' => 'id']); }
public function getSubjectName() { return Subject::findOne(['id' => $this->subject_id])->title; }
/** * Display the index page * * @return \Illuminate\Http\Response */ public function getIndex() { return new Response(view('index', ['subjectGroups' => Subject::all()->groupBy('group'), 'subjects' => Subject::all()])); }
/** * Show the form for editing the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function edit($society, $category, $id) { if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) { $data['society'] = $society; $data['subjects'] = Subject::orderBy('subject')->get(); $data['mission'] = Mission::find($id); $data['category'] = $category; return view('missions.edit', $data); } else { return view('shared.unauthorised'); } }
/** * Exclude object from result * * @param ChildSubject $subject Object to remove from the list of results * * @return $this|ChildSubjectQuery The current query, for fluid interface */ public function prune($subject = null) { if ($subject) { $this->addUsingAlias(SubjectTableMap::COL_ID, $subject->getId(), Criteria::NOT_EQUAL); } return $this; }
?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'description:html', 'answer', ['attribute' => 'section', 'value' => function ($model) { if ($model->section == 0) { return 'Русское'; } else { return 'Казахское'; } }], ['attribute' => 'cost', 'value' => function ($model) { if ($model->section == 0) { return 'Бесплатный'; } else { return 'Платный'; } }], ['attribute' => 'level', 'value' => function ($model) { if ($model->level == 0) { return 'Легкий'; } elseif ($model->level == 1) { return 'Средний'; } else { return 'Сложный'; } }], ['attribute' => 'subject_id', 'value' => function ($model) { return Subject::findOne(['id' => $model->subject_id])->title; }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
use yii\grid\GridView; use app\models\Question; use app\models\Subject; /* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Сложные вопросы'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="hard-question-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'description', 'format' => 'html', 'value' => function ($model) { return Question::findOne(['id' => $model->question_id])->description; }], ['attribute' => 'subject_id', 'value' => function ($model) { $subject_id = Question::findOne(['id' => $model->question_id])->subject_id; return Subject::findOne(['id' => $subject_id])->title; }], ['attribute' => 'section', 'value' => function ($model) { if (Question::findOne(['id' => $model->question_id])->section == 0) { return 'Русское'; } else { return 'Казахское'; } }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
/** * Search in Subject the Materials * * @param id * @return Response with materials */ public function getMaterials($id) { $subjects = Subject::find($id); return response()->json($subjects->materials); }
public function updateSubject($id, Subject $subject, Setting $setting, Request $request) { $title = $request->input('title'); $sub = $subject->find($id); $sub->title = $title; $sub->save(); session(array('subject_id' => $id)); $old_setting = $setting->find($id); $uploads_path = realpath(__DIR__ . '/../../../uploads'); if ($request->session()->has('uploads')) { if ($old_setting->lec_xlsx) { unlink($uploads_path . '/' . $old_setting->lec_xlsx); } if ($old_setting->lab_xlsx) { unlink($uploads_path . '/' . $old_setting->lab_xlsx); } } $sheet_number = $request->input('sheet_number'); $name_cell = $request->input('name_cell'); $grade_cell = $request->input('grade_cell'); $cell_range = $request->input('cell_range'); $header_row = $request->input('header_row'); $start_row = $request->input('start_row'); $end_row = $request->input('end_row'); $new_setting = array('sheet_number' => $sheet_number, 'name_cell' => $name_cell, 'grade_cell' => $grade_cell, 'cell_range' => $cell_range, 'header_row' => $header_row, 'start_row' => $start_row, 'end_row' => $end_row); if ($request->session()->has('uploads')) { $new_setting['lec_xlsx'] = session('uploads')[0]; $new_setting['lab_xlsx'] = session('uploads')[1]; } $setting = DB::table('settings')->where('subject_id', '=', $id)->update($new_setting); return redirect("activities/{$id}/add"); }
function getXoa($id) { $data['list_subjects'] = Subject::findOrFail($id); $data['list_subjects']->delete(); return redirect()->route('monhoc'); }
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aCourse) { $this->aCourse->removeEngagement($this); } if (null !== $this->aProfessor) { $this->aProfessor->removeEngagement($this); } if (null !== $this->aSubject) { $this->aSubject->removeEngagement($this); } if (null !== $this->aSchoolYear) { $this->aSchoolYear->removeEngagement($this); } $this->professor_id = null; $this->subject_id = null; $this->course_id = null; $this->school_year_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * Remove the specified resource from storage. * DELETE /subjects/{id} * * @param int $id * @return Response */ public function destroy($id) { $subject = Subject::find($id); $subject->delete(); return Redirect::route('subjects.index')->with('okmessage', 'Subject deleted'); }
public function destroy($id) { Subject::findOrFail($id)->delete(); \Flash::success('Mata pelajaran berhasil dihapus.'); return redirect()->back(); }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use app\models\Subject; $subjects = Subject::find()->all(); $lsubjects = ArrayHelper::toArray($subjects, ['app\\models\\Subject' => ['id', 'title', 'section' => function ($subject) { if ($subject->section == 0) { return 'Русское отделение'; } else { return 'Казахское отделение'; } }]]); $listOfSubjects = ArrayHelper::map($lsubjects, 'id', 'title', 'section'); /* @var $this yii\web\View */ /* @var $model app\models\SubjectTest */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="subject-test-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'subject_id')->dropDownList($listOfSubjects); ?> <div class="form-group">
/** * @return \yii\db\ActiveQuery */ public function getCsSubjs() { return $this->hasMany(Subject::className(), ['subj_id' => 'cs_subj_id'])->viaTable('course_subj', ['cs_crs_id' => 'crs_id']); }
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aPeriod) { $this->aPeriod->removeApplication($this); } if (null !== $this->aSubject) { $this->aSubject->removeApplication($this); } if (null !== $this->aStudent) { $this->aStudent->removeApplication($this); } if (null !== $this->aSchoolYear) { $this->aSchoolYear->removeApplication($this); } $this->id = null; $this->student_id = null; $this->subject_id = null; $this->period_id = null; $this->school_year_id = null; $this->application_date = null; $this->exam_date = null; $this->exam_time = null; $this->exam_score = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * Finds the Subject model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Subject the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Subject::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }