public function destroy(Training $training) { // delete $training->delete(); // redirect flash()->overlay('Data training berhasil dihapus!'); return redirect('training'); }
public static function getTrainingsForDate($date) { $start = $date->startOfDay()->toDateTimeString(); $end = $date->endOfDay()->toDateTimeString(); $trainings = Training::where('finished_at', '>=', $start)->where('finished_at', '<=', $end)->where('user_id', Auth::user()->id)->get(); return $trainings; }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $faqs = FAQ::whereid($id)->firstOrFail(); $trainings = Training::all(); return view('frequently_asked_questions.edit', compact('faqs'))->with('trainings', $trainings); return $faqs; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $trainings = Training::all(); $courses = Course::whereId($id)->firstOrFail(); $training_id = $courses->training_id; $training_name = $this->training_name_by_training_id($training_id); return view('course.edit', compact('courses', 'training_name', 'trainings')); }
public function index() { $limit = 3; $announcement = Announcement::orderBy('created_at', 'desc')->limit($limit)->get(); $trainings = Training::orderBy('start_date', 'asc')->get(); return view('bard_frontend.index', compact('announcement'), compact('trainings')); //return view('bard_frontend/index')->with('index', 'active'); }
public function index() { $limit = 2; $announcement = Announcement::orderBy('created_at', 'desc')->limit($limit)->get(); $now = new Datetime(); $now = $now->format('Y-m-d'); $upcomingTrainings = Training::where('status', '=', 1)->where('start_date', '>', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $now . ' 00:00:00'))->orderBy('start_date', 'asc')->limit($limit)->get(); $ongoingTrainings = Training::where('status', '=', 1)->where('start_date', '<=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $now . ' 00:00:00'))->where('end_date', '>=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $now . ' 00:00:00'))->limit($limit)->get(); $all_slider = Slider::orderBy('position', 'asc')->get(); return view('bard_frontend.index', compact('announcement', 'upcomingTrainings', 'ongoingTrainings', 'all_slider')); }
/** * Store training information * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\RedirectResponse */ public function store(Request $request) { $this->validate($request, ['f_name' => 'required', 'email' => 'required', 'phone' => 'required', 'location' => 'required']); Training::create($request->all()); // Mail send to admin $mailData = ['name' => $request->f_name . ' ' . $request->l_name, 'location' => $request->location, 'email' => $request->email, 'course' => $request->course, 'address' => $request->address, 'phone' => $request->phone, 'suburb' => $request->suburb, 'state' => $request->state, 'postcode' => $request->postcode, 'participant' => $request->participant, 'date' => $request->date, 'payment_method' => $request->payment_method, 'coupon' => $request->coupon]; // Send Mail Mail::send('emails.training', $mailData, function ($message) use($mailData) { $message->to('*****@*****.**', $mailData['name'])->subject($mailData['course']); }); Session::flash('message', 'Thanks for your interest!'); return redirect()->back(); }
public function delete_announcement($id) { if (Auth::User()->role == 1) { $training = Training::find($id); if ($training == null) { return redirect('/'); } else { $training->delete(); return redirect('/'); } } else { return redirect('/'); } }
public function addGroup(Request $request) { $data = array('id' => $request->input('id'), 'ziua' => $request->input('ziua'), 'ora' => $request->input('ora')); $rules = array('id' => 'exists:trainings,id', 'ziua' => 'required', 'ora' => 'required'); $validator = Validator::make($data, $rules); if (!$validator->fails()) { $training = Training::find($data['id']); $group = new Group(); $group->training_id = $data['id']; $group->trainer_id = $training->trainer_id; $group->area_id = $training->area_id; $group->subarea_id = $training->subarea_id; $group->data = $data['ziua']; $group->ora = $data['ora']; $group->save(); return redirect('/trainer'); } }
public function training() { $trg = Training::latest('created_at')->where('created_at', '<=', Carbon::now())->where('created_at', '<=', 'closing_date')->get(); return view('job.training', compact('trg')); }
public function one_year_report($start_date, $end_date) { $year = (int) substr($start_date, 0, 4) + 1; $courses_ids = []; $number_of_trainee = 0; $trainings = Training::whereBetween('start_date', [$start_date, $end_date])->get(); $number_of_trainings = $trainings->count(); foreach ($trainings as $training) { $courses = $this->course_by_training_id($training->id); $number_of_trainee += $this->number_of_trainee_by_training_id($training->id); foreach ($courses as $course) { $courses_ids[] = $course->id; } } $number_of_courses = count($courses_ids); $data = ['year' => $year, 'number_of_trainings' => $number_of_trainings, 'number_of_courses' => $number_of_courses, 'number_of_trainee' => $number_of_trainee]; return $data; }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request) { $training_id = $request->input('training_id'); $training = Training::find($training_id); if ($training && ($training->user_id == $request->user()->id || $request->user()->is_admin())) { $training->name = $request->input('name'); if ($request->has('save')) { $message = 'Training saved successfully'; $landing = 'exercise/index'; } $training->save(); return redirect($landing)->withMessage($message); } else { return redirect('/exercise/index')->withErrors('You have not sufficient permissions'); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { $exercises = Exercise::all(); $trainings = Training::all(); return view('exercises.index')->with('exercises', $exercises)->with('trainings', $trainings); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show() { $testimonials = Testimonial::all(); $trainings = Training::select('id', 'training_name')->get(); return view('testimonials.show', compact('testimonials', 'trainings')); }
public function get_announcements(Request $request) { $rules = array('month' => 'required'); $messages = array('month.required' => 'პერიოდი სავალდებულოა'); $this->validate($request, $rules, $messages); $field_search = input::get('field'); $term_search = input::get('term'); $region_search = input::get('region'); $municipalities_search = input::get('municipalities'); $month_search = input::get('month'); if ($field_search == '0' || empty($field_search)) { $fields_all = Field::all(['id']); foreach ($fields_all as $field) { $fields[] = $field->id; } } else { $fields[] = $field_search; } if ($term_search == '0' || empty($term_search)) { $terms_all = Term::all(['id']); foreach ($terms_all as $term) { $terms[] = $term->id; } } else { $terms[] = $term_search; } if ($municipalities_search[0] == '0' || empty($municipalities_search)) { if ($region_search != '0' && !empty($region_search)) { $any_municipality = Region::find($region_search)->get_municipalities()->get(); } else { $any_municipality = Municipality::all(['id']); } foreach ($any_municipality as $instance) { $municipality_id[] = $instance->id; } } else { $municipality_id = $municipalities_search; } if ($month_search[0] != '0' || !empty($month_search[0])) { $query_month = 'AND month_training.month_id in (' . implode(',', $month_search) . ')'; } else { $query_month = ''; } $select = DB::select(' SELECT trainings.id, field_training.field_id, term_training.term_id, municipality_training.municipality_id, month_training.month_id FROM trainings JOIN field_training ON trainings.id = field_training.training_id JOIN term_training ON trainings.id = term_training.training_id JOIN municipality_training ON trainings.id = municipality_training.training_id JOIN month_training ON trainings.id = month_training.training_id WHERE field_training.field_id in(' . implode(',', $fields) . ') AND term_training.term_id in ( ' . implode(',', $terms) . ') AND municipality_training.municipality_id in (' . implode(',', $municipality_id) . ') ' . $query_month . ' group by trainings.id '); foreach ($select as $instance) { $training_filtered = new \stdClass(); $training_instance = Training::find($instance->id); $training_field = Field::find($instance->field_id); $training_municipality = Municipality::find($instance->municipality_id); $training_months = DB::select('SELECT months.name FROM month_training JOIN months ON months.id = month_training.month_id WHERE training_id = ' . $instance->id); $training_terms = DB::select('SELECT terms.name FROM term_training JOIN terms ON terms.id = term_training.term_id WHERE training_id = ' . $instance->id); foreach ($training_months as $month) { $training_months_array[] = $month->name; } foreach ($training_terms as $term) { $training_terms_array[] = $term->name; } $training_filtered->id = $training_instance->id; $training_filtered->header = $training_instance->name; $training_filtered->description = $training_instance->description; $training_filtered->file = $training_instance->file; $training_filtered->link = $training_instance->link; $training_filtered->field = $training_field->name; $training_filtered->months = implode(',', $training_months_array); $training_filtered->terms = implode(',', $training_terms_array); $training_filtered->municipality = $training_municipality->name; $training_filtered->isAdmin = !(!Auth::user() || Auth::user()->role == 100); $training_filtered_array[] = $training_filtered; unset($training_filtered); unset($training_months_array); unset($training_terms_array); } return response(json_encode($training_filtered_array), 200)->header('Content-Type', 'application/json'); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show() { $testimonials = Testimonial::orderBy('created_at', 'desc')->get(); $trainings = Training::select('id', 'training_name')->get(); return view('testimonials.show', compact('testimonials', 'trainings')); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $training_names = Training::all(); return view('testimonials/create_testimonial', compact('training_names')); }
/** * Remove old posts. * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function clean() { $trainings = Training::all(); $matches = Match::all(); foreach ($matches as $match) { if ($match->kickoff < Carbon::now()->subHours(6)) { $match->delete(); } } foreach ($trainings as $training) { if ($training->date_time < Carbon::now()->subHours(3)) { $training->delete(); } } return redirect('/'); }
public function trainerSelect($id) { //$id is id of training. $this->info['training'] = Training::find($id); if ($this->info['training']->trainer_id == Auth::user()->id) { $this->info['namespace'] = "trainerIndex"; $this->info['title'] = "Selecteaza Participanti | " . $this->info['title']; return view('trainerPages.select', ['info' => $this->info]); } else { return redirect('/trainer'); } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update($training_slug, TrainingFormRequest $request) { // $training = Training::where('training_slug', $training_slug)->firstOrFail(); $training->training_name = $request->get('training_name'); $training->training_type = $request->get('training_type'); $training->applying_information = $request->get('applying_information'); $training->objectives = $request->get('objectives'); $training->courses = $request->get('courses'); $training->start_date = $request->get('start_date'); $training->end_date = $request->get('end_date'); $training->provided_resources = $request->get('provided_resources'); $training->accommodation = $request->get('accommodation'); $training->testimonial = $request->get('testimonial'); $training->daily_schedule = $request->get('daily_schedule'); $training->fees_structure = $request->get('fees_structure'); $training->responsible_person = $request->get('responsible_person'); Training::where('training_slug', $training_slug)->update($training->toArray()); return redirect(action('TrainingController@edit', $training->training_slug))->with('status', 'The Training Information has been updated!'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $training = Training::whereid($id)->firstOrFail(); $training->delete(); return redirect('/trainings')->with('status', 'The training information has been deleted!'); }
public function trainings() { $trainings = Training::whereStatus(1)->get(); return view('trainers.trainingLists', compact('trainings')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function training_name_by_training_id($training_id) { $training = Training::whereId($training_id)->firstOrFail(); return $training->training_name; }
public function selectTraining() { $trainings = Training::lists('training_name', 'id'); return view('traineeCourse/selectTraining', compact('trainings')); }
public function deltr($id) { if (Auth::guest()) { \Session::flash('msg', ' No Permission for that Request'); return redirect('job'); } $trg = Training::findOrFail($id); if (Auth::id() != $trg['Employer_id']) { \Session::flash('msg', ' No Permission for that Request'); return redirect('job'); } if (Training::find($id)->delete()) { \Session::flash('msg', 'You Have Successfully Deleted Training : ' . $trg->title); return redirect('job/training'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $training = Training::whereid($id)->firstOrFail(); unlink($training->image_path); $training->delete(); return redirect('/trainings')->with('status', 'The Training Information Has Been Deleted!'); }
public function save_announcement(Request $request) { if (!Auth::user() || Auth::user()->role != 1) { return redirect('/'); } $rules = array('term' => 'required', 'field' => 'required', 'region' => 'required', 'month' => 'required'); $messages = array('term.required' => 'სწავლების ფორმა სავალდებულოა', 'field.required' => 'სწავლების სფერო სავალდებულოა', 'region.required' => 'ჩატარების ადგილი სავალდებულოა', 'month.required' => 'ჩატარების პერიოდი სავალდებულოა'); $input = input::all(); $file = Input::file('file'); if (isset($file) && !empty($file)) { $extension = $file->getClientOriginalExtension(); if ($extension != 'pdf') { $rules['pdf'] = 'required'; $messages['pdf.required'] = 'დასაშვებია მხოლოდ pdf გაფართოების ფაილები'; } } $this->validate($request, $rules, $messages); if (isset($file) && !empty($file)) { $file_name = str_random(10) . '.' . $file->getClientOriginalExtension(); $destinationPath = 'training_pdf'; $file->move($destinationPath, $file_name); $input['file'] = $file_name; } $training_to_delete = Training::find(input::get('id')); $training_to_delete->delete(); $training = Training::create($input); foreach (input::get('term') as $term) { $training->terms()->attach($term); } $training->fields()->attach(input::get('field')); $training->municipalities()->attach(input::get('municipalities')); if (!is_null(input::get('month'))) { foreach (input::get('month') as $month) { $training->months()->attach($month); } } $training->save(); return redirect('/'); }
public function ajax_meal(Request $request) { if ($request->ajax()) { $now = Carbon::now(); $now = $now->toDateString(); $day = $request->input('day'); $year = $request->input('year'); $month = $request->input('month'); $selected_date = Carbon::create($year, $month, $day); $date = $selected_date; $user_id = Auth::user()->id; $meals_with_totals = Meal::getMealsWithTotals($date->toDateString(), $user_id); extract($meals_with_totals); // thsi will create $meals, $meals_planed and $totals and $totals_planned $bmr = Auth::user()->getUserBmr(); $training_done = Training::getTrainingsForDate($selected_date); $meals = $meals_with_totals["meals"]; $returnHTML = view('meals.ajax_meal')->with(compact(array('meals', 'meals_planed', 'title', 'date', 'totals', 'totals_planed', 'now', 'training_done', 'bmr')))->render(); return response()->json(array('success' => true, 'html' => $returnHTML)); } else { echo 'Error'; } }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $training = Training::lists('training_name', 'id'); //dd($training); $data = UserTraining::whereid($id)->firstOrFail(); //dd($data); $trainees = User::lists('name', 'id'); return view('user_traininginfo/edit', compact('data', 'training', 'trainees')); }
public function forceDelete($id) { return Training::withTrashed()->where('id', $id); }