public function editItem(AcceptanceTester $I) { $q = Question::get()->random(); $I->wantTo('show edit page'); $I->amOnRoute('admin.q.edit', ['id' => $q->id]); $I->seeInField('title', $q->title); }
public function reviewApplication(Application $application, Request $request) { // Did the current user create this application? if ($application->user->id != Auth::user()->id) { // If not, are they authorized to view applications? if (!(Auth::user()->can('view-application') || Auth::user()->can('view-submitted-application') && $application->status != 'new')) { $request->session()->flash('error', 'You are not authorized to view this application.'); return redirect('/login'); } } $questions = Question::get(); $criteria = ['objective' => Criteria::where('type', 'objective')->get(), 'subjective' => Criteria::where('type', 'subjective')->get()]; // Generate an array of answers based on their associated question ID $answers = []; foreach ($application->answers as $answer) { $answers[$answer->question_id] = $answer; } $scores = []; // Select all scores made by the current user foreach ($application->scores()->where('user_id', Auth::user()->id)->get() as $score) { $scores[$score->criteria_id] = $score; } $judged = Judged::where(['application_id' => $application->id, 'user_id' => Auth::user()->id])->get()->first(); return view('pages/applications/review', compact('application', 'questions', 'answers', 'criteria', 'scores', 'judged')); }