Пример #1
0
 function createFeedback(FeedbackRequest $request)
 {
     // Double check to make sure the current user is authorized to do this...
     $this->authorize('create-feedback');
     $input = $request->all();
     // Check application ID
     $application = Application::find($input['application_id']);
     // Check regarding ID / type, Note, nothing to be done for 'general' feedback
     if ($input['regarding_type'] == 'question') {
         $regarding = Question::find($input['regarding_id']);
     } elseif ($input['regarding_type'] == 'document') {
         // todo
     }
     // Create new feedback
     $feedback = new Feedback();
     $feedback->application_id = $application->id;
     $feedback->regarding_type = $input['regarding_type'];
     if (isset($regarding) && $regarding->exists) {
         $feedback->regarding_id = $regarding->id;
     }
     // Set the current judge ID for a record of who requested this feedback
     $feedback->user_id = Auth::user()->id;
     $feedback->save();
     $feedback->update($input);
     // Notify applicant of new feedback requested
     event(new FeedbackChanged($feedback, ['status' => 'created']));
     $request->session()->flash('success', 'Your feedback has been requested.');
     return redirect('/applications/' . $application->id . '/review');
 }