public function search(Request $request) { $results = array(); $term = $request->get('term'); $goals = Goal::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get(); $objectives = Objective::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get(); $actions = Action::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get(); $tasks = Task::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get(); $teams = Team::where('name', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get(); $departments = Department::where('name', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get(); $users = User::where('name', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get()->all(); foreach (User::where('email', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get() as $matching_user_email) { if (in_array($matching_user_email, $users)) { continue; } $users[] = $matching_user_email; } $notes = Note::where('content', 'like', '%' . $term . '%')->orderBy('content', 'asc')->get(); $types = [$goals, $objectives, $actions, $tasks, $teams, $departments, $users, $notes]; foreach ($types as $type) { foreach ($type as $result) { $results[] = $result; } } return view('search.show')->with('results', $results)->with('term', $term); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $goal = Goal::find($id); if (!$goal->user_id == Auth::id()) { return redirect('goal/create')->with('message', 'this is not your page'); } return view('goal.show.main', compact('goal')); }
/** * Run the database seeds. * * @return void */ public function run() { $categories = [['name' => 'The Basics', 'weight' => 1], ['name' => 'Bonus Points', 'weight' => 2]]; $goals = [['name' => 'Slept 6-8 hours last night', 'points' => 10, 'weight' => 1, 'category_id' => 1], ['name' => 'Exercised for at least 30 mins', 'points' => 10, 'weight' => 2, 'category_id' => 1], ['name' => 'Drank at least 4 glasses of water', 'points' => 10, 'weight' => 3, 'category_id' => 1], ['name' => 'Ate a healthy lunch', 'points' => 10, 'weight' => 4, 'category_id' => 1], ['name' => 'Purposeful exercise (run, gym, etc.)', 'points' => 15, 'weight' => 1, 'category_id' => 2], ['name' => 'Ate home-cooked dinner', 'points' => 15, 'weight' => 2, 'category_id' => 2], ['name' => 'Avoided caffeine', 'points' => 15, 'weight' => 3, 'category_id' => 2], ['name' => 'Avoided refined sugar (treats)', 'points' => 15, 'weight' => 4, 'category_id' => 2], ['name' => 'Took 2 or more breaks from screen', 'points' => 15, 'weight' => 5, 'category_id' => 2]]; foreach ($categories as $cat) { Category::create($cat); } foreach ($goals as $goal) { Goal::create($goal); } }
public function addGoal(Request $request, Plan $plan) { if (isset($request->add)) { $newgoal = Goal::create($request->all()); $newgoal->plan_id = $plan->id; $newgoal->save(); return view('plans.addgoals')->with('plan', $plan); } else { return view('plans.addobjectives')->with('plan', $plan); } }
public function remove(Goal $goal) { if ($goal->body == "Non-Business Plan") { return back(); } foreach ($goal->objectives as $objective) { foreach ($objective->actions as $action) { foreach ($action->tasks as $task) { Task::destroy($task->id); } Action::destroy($action->id); } Objective::destroy($objective->id); } Goal::destroy($goal->id); return redirect('/plan'); }
function deleteGoal($idbp, $id) { Log::info('This is some useful information.'); Log::info($id); Goal::findOrFail($id)->delete(); return; }
public function getGoals(Request $request) { return Goal::orderBy('weight', 'asc')->get(); }
public function getBusinessPlan($name) { $goals = Goal::All(); $goal = $goals->where("name", "=", $name)->first(); return $goal->bpid; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Goal::destroy($id); return redirect('/back/goals'); }
public function destroy(Request $request, $lecture_id, $goal_id) { $goal = Goal::find($goal_id); $goal->delete(); return redirect('/lectures/' . $lecture_id . '/goals'); }
public function removeGoal(Request $request) { $return['status'] = false; $return['errors'] = []; if ($request->has('project_id')) { $project_id = $request->get('project_id'); $project = Project::find($project_id); if ($project && $project->user_id == $this->user->id && $project->status == 0) { $goalid = $request->get('goalid'); $goal = Goal::find($goalid); if ($goal->project_id == $project_id) { $goal->delete(); $return['status'] = true; $return['message'] = ['Зорилт устгагдлаа']; } } else { $return['status'] = false; $return['errors'] = ['Таны төсөл биш байна']; } } else { $return['status'] = false; $return['errors'] = ['Төслийн АйДи байхгүй байна']; } return $return; }