コード例 #1
0
 public function destroy($id)
 {
     $solucion = Solution::find($id);
     $solucion->delete();
     $result = Result::find($solucion->results_id);
     $result->res_status = 0;
     $result->save();
     return 'Elemento eliminado';
 }
コード例 #2
0
ファイル: Task.php プロジェクト: mikolajszczepanski/NuPtr
 public static function resolveTaskDependencies(&$task, $categories = null)
 {
     if (!$categories) {
         $categories = Category::getAllFromCache();
     }
     $task->category_name = $categories[$task->category_id - 1]->name;
     $cache_name = __METHOD__ . '_task_id=' . $task->id;
     $task->files = Cache::remember($cache_name, Config::get('constants.CACHE_TIME_DAY'), function () use($task, $cache_name) {
         if (App::environment('local')) {
             Log::debug('Cache: ' . $cache_name);
         }
         return TaskFile::where('task_id', $task->id)->where('deleted', false)->select('id', 'name', 'user_id', 'task_id', 'created_at', 'updated_at')->get();
     });
     $task->solutions = Solution::getTaskSolutionsDependencies($task->id);
 }
コード例 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  Solution $solution
  * @return Response
  */
 public function destroy($solution)
 {
     $solution->delete();
 }
コード例 #4
0
 public function delete(Request $request)
 {
     $this->validate($request, ['solution_id' => 'required|numeric']);
     $solution_id = $request->input('solution_id');
     $solution = Solution::where('id', $solution_id)->where('deleted', false)->where('user_id', Auth::user()->id)->first();
     if (!$solution) {
         abort(404);
     }
     $solution->deleted = true;
     $pass = $solution->save();
     $this->clearCache($solution);
     if ($pass) {
         Alert::setSuccessAlert(Lang::get('app.deleted_solution'));
     } else {
         Log::alert(__METHOD__ . '(' . __FILE__ . ')', array('solution_id' => $solution->id, 'user_id' => Auth::user()->id));
         Alert::setErrorAlert(Lang::get('app.unknown_error'));
     }
     Statistic::SubSolution();
     return redirect()->action('UserController@solutions');
 }
コード例 #5
0
 public function solutions()
 {
     $user_id = Auth::user()->id;
     $solutions = DB::table('solutions')->join('tasks', 'solutions.task_id', '=', 'tasks.id')->where('solutions.user_id', $user_id)->where('solutions.deleted', false)->where('tasks.deleted', false)->orderBy('solutions.created_at', 'desc')->select('solutions.*', 'tasks.name AS task_name')->paginate(15);
     Solution::resolveSolutionsFiles($solutions);
     return view('user/solutions', ['solutions' => $solutions]);
 }
コード例 #6
0
ファイル: Solution.php プロジェクト: mikolajszczepanski/NuPtr
 public static function resolveSolutionsFiles(&$solutions)
 {
     foreach ($solutions as $solution) {
         Solution::resolveSolutionFiles($solution);
     }
 }