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'; }
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); }
/** * Remove the specified resource from storage. * * @param Solution $solution * @return Response */ public function destroy($solution) { $solution->delete(); }
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'); }
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]); }
public static function resolveSolutionsFiles(&$solutions) { foreach ($solutions as $solution) { Solution::resolveSolutionFiles($solution); } }