public function mySchool() { // $academy_id = Session::get('school_id_session'); $academy_id = Cookie::get('school_id_session'); $mySchool = Academy::where('id', $academy_id)->first(); return $mySchool; }
public function index() { $academies = Academy::all(); // $academy_id = Session::get('school_id_session'); $academy_id = Cookie::get('school_id_session'); $school = Academy::where('id', $academy_id)->first(); // dd(var_dump($school)); if ($school != NULL) { return Redirect::to("/school/{$academy_id}"); } return View::make('home.index')->with('academies', $academies); }
public static function get($academy_id) { $academy = Academy::where('id', $academy_id)->first(); return $academy; }
public function academyDetail($academy_id) { $academy = Academy::where('id', $academy_id)->first(); $majors = $academy->major; return View::make('admin.academyDetail')->with('academy', $academy)->with('majors', $majors); }
public function detail($task_id) { $task = Task::where('id', $task_id)->first(); // dd($task->attachment); if ($task->user->active == false || $task->state == 0) { return View::make('task.closed'); } $prev_task = Task::where('id', $task_id + 1)->first(); $next_task = Task::where('id', $task_id - 1)->first(); $school = Academy::where('id', $task->place)->first(); View::share('task_id', $task_id); View::share('task', $task); View::share('prev_task', $prev_task); View::share('next_task', $next_task); View::share('school', $school); View::share('attachment', $task->attachment); View::share('categories', Category::all()); Session::set('task_id_session', $task_id); if ($task->type == 1) { $commit_sum = count(CommitPivot::where(['task_id' => $task_id])->get()); } else { if ($task->type == 2) { $quote_sum = count(QuotePivot::where(['task_id' => $task_id])->get()); $quote_price_sum = 0; $quote_price_avg = 0; $bidder_count = 0; foreach ($task->bidder as $bidder) { $bidder_count++; $quote_price_sum += $bidder->findLatestQuoteById($bidder->id, $task->id)->first()->price; } if ($bidder_count != 0) { $quote_price_avg = $quote_price_sum / $bidder_count; } else { $quote_price_avg = 0; } } } if (Auth::guest()) { if ($task->type == 1) { return View::make('task.detail')->with('commit_sum', $commit_sum); } else { if ($task->type == 2) { return View::make('task.detail')->with('quote_sum', $quote_sum)->with('quote_price_avg', $quote_price_avg); } } } if (Auth::check()) { if ($task->type == 1) { if ($task->user_id == Auth::user()->id) { $all_commits = CommitPivot::where(['task_id' => $task_id]); } else { if (Auth::user()->isBidder($task_id)) { $all_commits = CommitPivot::where(['task_id' => $task_id, 'user_id' => Auth::user()->id]); } else { return View::make('task.detail')->with('commit_sum', $commit_sum); } } $commits = $all_commits->orderBy('created_at', 'desc')->paginate(5); // $commits = 's'; return View::make('task.detail')->with('commits', $commits)->with('commit_sum', $commit_sum); } else { if ($task->type == 2) { if ($task->user_id == Auth::user()->id) { $all_quotes = QuotePivot::where(['task_id' => $task_id]); } else { if (Auth::user()->isBidder($task_id)) { $all_quotes = QuotePivot::where(['task_id' => $task_id, 'user_id' => Auth::user()->id]); } else { return View::make('task.detail')->with('quote_sum', $quote_sum)->with('quote_price_avg', $quote_price_avg); } } $quotes = $all_quotes->orderBy('created_at', 'desc')->paginate(5); return View::make('task.detail')->with('quotes', $quotes)->with('quote_sum', $quote_sum)->with('quote_price_avg', $quote_price_avg); } } } }