Esempio n. 1
0
 public function store(CreateProblemRequest $request)
 {
     if (!$request->isFileFieldOK('statement')) {
         abort(409, 'No se completó el envío del archivo al servidor.');
     }
     $problem = Problem::create($request->all());
     $problem->updateStatementFromRequest($request);
     Flash::success('Se ha guardado el problema.');
     return redirect('problems');
 }
Esempio n. 2
0
 public function update(Requests\CreateProblemRequest $request, $id)
 {
     $problem = ProblemService::getProblem($id);
     if (!$this->amIAuthorOfProblem($problem->id)) {
         return abort(404);
     }
     ProblemService::updateProblem($problem->id, $request->all());
     $limitTagCount = TagService::getLimitTagCount();
     $tags = $request->get('tags');
     if (count($tags) > $limitTagCount) {
         return redirect()->back()->withErrors('태그는 최대 ' . $limitTagCount . '개까지만 등록할 수 있습니다.');
     }
     TagService::insertTags($problem->id, (array) $tags);
     if ($problem->status == Problem::openCode) {
         return redirect(action('ProblemsController@show', $problem->id));
     } else {
         return redirect(action('ProblemsController@preview', $problem->id));
     }
 }