public function show($id)
 {
     $activity = Activity::findOrFail($id);
     $activity->load('members.user');
     $activity->load('comments.user');
     $user = [];
     $joined = false;
     $member = null;
     if (Auth::check()) {
         $user = User::findOrFail(Auth::user()->id);
         $joined = ActivityMember::isJoined($id, $user->id);
         $member = ActivityMember::where('activity_id', $id)->where('user_id', $user->id)->first();
         if ($member != null) {
             $member->load('activity');
         }
     }
     $photos = Product::findOrFail($activity->product_id)->photos;
     $members = $activity->members;
     $activities = Activity::where('istop', 1)->orderBy('order_number')->take(5)->get();
     $activities = $activities->filter(function ($item) use($activity) {
         return $item->id != $activity->id;
     });
     $models = compact('activity', 'members', 'photos', 'joined', 'activities');
     if (Auth::check()) {
         $models['user'] = $user;
         $models['member'] = $member;
     }
     return view('activity.show', $models);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $activities = Activity::where('type', 'Run')->orderBy('start_date_local', 'desc')->get();
     foreach ($activities as $activity) {
         $activity->details = 0;
         $activity->save();
     }
 }
Esempio n. 3
0
 public function byLoan($id, Manager $fractal, ActivityTransformer $activityTransformer)
 {
     // show all
     $records = Activity::where('loan_id', $id)->get();
     $collection = new Collection($records, $activityTransformer);
     $data = $fractal->createData($collection)->toArray();
     return $this->respond($data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($id, $occId)
 {
     $eventOccurrence = EventOccurrence::where('event_id', $id)->findOrFail($occId);
     //refaktoroikaa tää :D
     $activities = Activity::where('age_group', $eventOccurrence->event->group->age_group)->whereNotIn('id', $eventOccurrence->activities()->get()->map(function ($item, $key) {
         return $item->id;
     }))->get();
     return view('eventActivities', compact('eventOccurrence', 'activities'));
 }
Esempio n. 5
0
 public function getActivityOfOneMonth($month, $year)
 {
     $date = Carbon::create($year, $month, 1, 0);
     $initial_date = $date->toDateString();
     $last_date = $date->addMonth()->subDay()->toDateString();
     $trucks = Car::lists('name');
     $activities = Activity::where('date', '>=', $initial_date)->where('date', '<=', $last_date)->get();
     return $activities;
 }
Esempio n. 6
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('inspire')->hourly();
     // Delete user activity older than 30 days
     $schedule->call(function () {
         Activity::where('created_at', '<', date('Y-m-d H:i:s', strtotime("-1 month")))->delete();
     })->daily();
     $schedule->command('bill:run')->daily();
 }
Esempio n. 7
0
 public function index()
 {
     $activities = Activity::where('istop', 1)->where('states', 0)->orderBy('order_number')->get();
     $guides = Guide::where('isbest', '=', 1)->orderBy('orders')->take(6)->get();
     $topNotes = Note::topNotes()->with('user')->take(6)->get();
     //$users = User::topUsers()->take(10)->get();
     $adverts = Banner::where('tag', 'indexAdvert')->take(2)->get();
     $banners = Banner::where('tag', 'indexBanner')->orderBy('orders')->get();
     return view('index', compact('activities', 'guides', 'topNotes', 'adverts', 'banners'));
 }
Esempio n. 8
0
 public function show($id)
 {
     $user = JWTAuth::parseToken()->authenticate();
     $activity = Activity::where('id', $id)->where('user_id', $user['id'])->first();
     if ($activity == null) {
         return $this->respondError('NOT_FOUND', []);
     } else {
         return $this->respondSuccess('SUCCESS', Activity::transformOut($activity));
     }
 }
 /**
  * Run the database seeds. 
  * As a result of this database seeder script, 4 sessions will be created for the 
  * 'CM1103 Python Programming Lab' support activity, for which a single 
  * Demonstrator' role is assumed to be required
  *
  * @return void
  */
 public function run()
 {
     //truncate the activities table so that the auto incrementing 'id' field starts counting from 1 again
     DB::table('sessions')->truncate();
     $activtiesCSVFile = new CsvFile(__DIR__ . '/_data/SessionsData.csv');
     foreach ($activtiesCSVFile as $currentRow) {
         //maybe make it w0rth with get(); s0meh0w
         $supportActivity = Activity::where('title', '=', $currentRow[0])->first();
         $Session = Session::create(['activity_id' => $supportActivity->id, 'date_of_session' => trim($currentRow[1]), 'start_time' => trim($currentRow[2]), 'end_time' => trim($currentRow[3]), 'location' => trim($currentRow[4])]);
     }
 }
Esempio n. 10
0
 /**
  * Handle the event.
  *
  * @param  UnFeedableEvent  $event
  * @return void
  */
 public function handle(UnFeedableEvent $event)
 {
     if ($event->gettype() == "CommentDeleted") {
         $subject = $event->getSubject();
         $lastActivity = Activity::where('subject_id', '=', $subject->id)->where('subject_type', '=', get_class($subject))->where('type', '=', 'CommentPosted')->last();
         $lastActivity->delete();
     } elseif ($event->gettype() == "SprintDeleted") {
         $subject = $event->getSubject();
         $lastActivity = Activity::where('subject_id', '=', $subject->id)->where('subject_type', '=', get_class($subject))->where('type', '=', 'SprintDeleted')->last();
         $lastActivity->delete();
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function consulta(Request $request)
 {
     $proyecto_etapa = Project::where('projects.id', '=', $request->get('project_id'))->join('project_stage', 'project_stage.project_id', '=', 'projects.id')->join('stages', 'stages.id', '=', 'project_stage.stage_id')->where('stages.id', '=', $request->get('stage_id'))->get(['project_stage.id as id', 'stages.name as name']);
     $actividad_etapa = Activity_Stage::where('activity_id', '=', $request->get('activity_id'))->where('stage_project_id', '=', $proyecto_etapa->last()->id)->get();
     if (count($actividad_etapa) > 0) {
         $especificaciones = Spacification::where('activity_id', '=', $actividad_etapa->last()->id)->get();
     } else {
         $especificaciones = '';
     }
     $etapa = stage::where('id', '=', $request->get('stage_id'))->first();
     $proyecto = Project::where('id', '=', $request->get('project_id'))->first();
     $actividad = Activity::where('id', '=', $request->get('activity_id'))->first();
     return response()->json(['actividad_etapa' => $actividad_etapa, 'etapa' => $etapa->name, 'especificaciones' => $especificaciones, 'proyecto' => $proyecto->name, 'actividad' => $actividad->name, 'project_id' => $proyecto->id, 'stage_id' => $etapa->id, 'activity_id' => $actividad->id, 'project_stage_id' => $proyecto_etapa->first()->id]);
 }
Esempio n. 12
0
 public function getActivity($city_id = 0)
 {
     $res = ['response' => 'YES', 'status' => '1', 'data' => []];
     if ($city_id == 0) {
         $activitys = Activity::where('activity_active', '=', '1');
     } else {
         $activitys = Activity::whereRaw('( ( activity_active = 1 AND activity_city_id = 0 ) OR ( activity_active = 1 AND activity_city_id = ' . $city_id . ' ) )');
     }
     $activitys = $activitys->orderBy('activity_city_id', 'ASC')->orderBy('activity_sort', 'ASC')->get();
     foreach ($activitys as $activity) {
         $img = $activity->img()->first();
         $res['data'][] = ['id' => $activity->activity_id, 'city_id' => $activity->activity_city_id, 'sort' => $activity->activity_sort, 'title' => $activity->activity_title, 'author' => $activity->activity_author, 'summary' => $activity->activity_summary, 'url' => MAPI_HOST . 'activity/' . $activity->activity_url, 'imgs' => [MAPI_IMG_HOST . $img->img_square, MAPI_IMG_HOST . $img->img_tiny, MAPI_IMG_HOST . $img->img_small, MAPI_IMG_HOST . $img->img_big, MAPI_IMG_HOST . $img->img_hd]];
     }
     return response()->json($res)->header('Content-Type', 'application/json');
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $key = $request->input('key');
     $states = $request->input('states');
     if (!$states) {
         $states = 0;
     }
     $query = Activity::where('states', $states);
     if ($key) {
         $query->where(function ($query) use($key) {
             $query->where('title', 'like', '%' . $key . '%')->orWhere('place', 'like', '%' . $key . '%');
         });
     }
     $query->orderBy('order_number', 'asc');
     $activities = $query->paginate(20);
     return view('admin.activity.index', compact('key', 'activities', 'states'));
 }
 public function run()
 {
     $faker = Faker::create();
     DB::table('activity_log')->delete();
     // Gets an array with event IDs and an array with user IDs.
     $cerf_ids = Cerf::all()->lists('id')->toArray();
     $user_ids = User::all()->lists('id')->toArray();
     for ($counter = 0; $counter < 30; $counter++) {
         // Chooses random keys in both arrays.
         $rand_cerf_id = $cerf_ids[array_rand($cerf_ids)];
         $rand_user_id = $user_ids[array_rand($user_ids)];
         // No two activity records should have the same user_id and cerf_id combination.
         if (Activity::where('user_id', '=', $rand_user_id)->where('cerf_id', '=', $rand_cerf_id)->exists()) {
             continue;
         }
         Activity::create(array('user_id' => $rand_user_id, 'cerf_id' => $rand_cerf_id, 'service_hours' => $faker->randomDigit, 'planning_hours' => $faker->randomDigit, 'traveling_hours' => $faker->randomDigit, 'admin_hours' => $faker->randomDigit, 'social_hours' => $faker->randomDigit, 'mileage' => $faker->randomDigit, 'notes' => $faker->paragraph));
     }
 }
Esempio n. 15
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '1', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '2', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '3', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '4', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '5', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '6', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '7', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Gentle Yoga')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '2', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Gentle Yoga')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '3', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Gentle Yoga')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '7', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Fun Run')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '3', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Fun Run')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '5', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '2', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '3', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '4', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '5', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '6', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Happy Hour')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '6', 'activity_id' => $activity_id]);
     $activity_id = \App\Activity::where('name', '=', 'Playground')->pluck('id');
     DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '1', 'activity_id' => $activity_id]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //get the first PHD student whose name is 'Alicia Reid'
     $phdStudent = User::where('name', '=', 'Alicia Reid')->first();
     //get the first job whose 'title' is 'CM1103 Python Programming Lab'
     $supportActivity = Activity::where('title', '=', 'CM1103 Python Programming Lab')->first();
     /*
         assign the PHD student to all the sessions for the 'CM1103 Python Programming Lab' job
         (5 sessions of two hours each as is produced by the 'SessionsSeeder' class) by inserting an
         entry in the pivot table as shown in 
         https://laravel.com/docs/5.2/eloquent-relationships#inserting-many-to-many-relationships
     */
     $assignments = $phdStudent->sessions()->attach($supportActivity->sessions->pluck('id')->all());
     //get the first job whose 'title' is 'CM1103 Discrete Maths Tutorial'
     $supportActivity = Activity::where('title', '=', 'CM1103 Discrete Maths Tutorial')->first();
     /*
         assign the PHD student to all the sessions for the 'CM1103 Python Programming Lab' job
         (5 sessions of two hours each as is produced by the 'SessionsSeeder' class) by inserting an
         entry in the pivot table as shown in 
         https://laravel.com/docs/5.2/eloquent-relationships#inserting-many-to-many-relationships
     */
     $assignments = $phdStudent->sessions()->attach($supportActivity->sessions->pluck('id')->all());
 }
 /**
  * Show stats from best efforts.
  *
  * @param  Request  $request
  * @return Response
  */
 public function stats(Request $request)
 {
     $activities = Activity::where('user_id', $request->user()->id)->where('start_date_local', '>', '2015-01-01')->orderBy('start_date_local', 'asc')->get();
     $monthly_totals = [];
     $month_array = [];
     $distance_array = [];
     $month_string = "";
     $distance_strings = [];
     //$distances = array( '400m', '1/2 mile', '1 mile', '2 mile', '5k', '10k', '15k', '10 mile', '20k' );
     $distances = array('400m', '1/2 mile');
     foreach ($activities as $activity) {
         if (!isset($monthly_totals[date('m/Y', strtotime($activity->start_date_local))])) {
             $monthly_totals[date('m/Y', strtotime($activity->start_date_local))] = [];
         }
         if (!isset($monthly_totals[date('m/Y', strtotime($activity->start_date_local))][$activity->type])) {
             $monthly_totals[date('m/Y', strtotime($activity->start_date_local))][$activity->type] = ['distance' => 0, 'time' => 0];
         }
         $monthly_totals[date('m/Y', strtotime($activity->start_date_local))][$activity->type]['distance'] += $activity->distance * 0.000621371;
         $monthly_totals[date('m/Y', strtotime($activity->start_date_local))][$activity->type]['time'] += $activity->moving_time;
         $best_efforts = $activity->bestEfforts()->orderBy('start_date_local', 'desc')->get();
         if (count($best_efforts)) {
             foreach ($best_efforts as $best_effort) {
                 if (!isset($monthly_totals[date('m/Y', strtotime($activity->start_date_local))][$activity->type][$best_effort->name])) {
                     $monthly_totals[date('m/Y', strtotime($activity->start_date_local))][$activity->type][$best_effort->name] = $best_effort->moving_time;
                 }
                 if ($best_effort->moving_time < $monthly_totals[date('m/Y', strtotime($activity->start_date_local))][$activity->type][$best_effort->name]) {
                     $monthly_totals[date('m/Y', strtotime($activity->start_date_local))][$activity->type][$best_effort->name] = $best_effort->moving_time;
                 }
             }
         }
     }
     foreach ($monthly_totals as $month => $totals) {
         $month_array[] = "'" . $month . "'";
         foreach ($distances as $distance) {
             if (!isset($distance_array[$distance])) {
                 $distance_array[$distance] = [];
             }
             if (isset($totals['Run'][$distance])) {
                 $distance_array[$distance][] = round($totals['Run'][$distance], 2);
             } else {
                 $distance_array[$distance][] = 0;
             }
         }
     }
     foreach ($distance_array as $distance => $results) {
         $distance_strings[$distance] = implode(",", $results);
     }
     return view('strava.stats', ['months' => implode(",", $month_array), 'distances' => $distance_strings]);
 }
 public function acceptedRequestsView($user_id, $student_id, $req_id, $act_id)
 {
     $user = UserMod::where('id', $user_id)->where('role', '=', 'Administrator')->first();
     if (UserMod::where('id', $user_id)->where('role', '=', 'Administrator')->exists() and PhDStudent::where('user_id', $student_id)->exists() and AddRequest::where('status', '=', 'Accepted')->where('id', $req_id)->where('user_id', $student_id)->where('activity_id', $act_id)->exists()) {
         $Phd = PhDStudent::where('user_id', $student_id)->with('user')->with('supervisor')->first();
         $request = AddRequest::where('status', '=', 'Accepted')->with('activity')->with('phd')->first();
         $activity = Activity::where('id', $act_id)->with('module')->first();
         $sessions = ActSession::where('activity_id', $act_id)->get();
         if (AddRequest::where('status', '=', 'Accepted')->exists()) {
         } else {
             Session::flash('no_requests', "Looks like you have no requests that were accepted!");
         }
         return View::make("Admin-req-accepted-view")->with('request', $request)->with('activity', $activity)->with('user', $user)->with('sessions', $sessions)->with('Phd', $Phd);
     } else {
         Session::flash('failed', "Something went wrong, please try again!");
         return back()->withInput();
     }
 }
 public function DeleteModuleActSession($user_id, $module_id, $act_id, $sess_id)
 {
     if (UserMod::where('id', $user_id)->where('role', '=', 'Lecturer')->exists() and Module::where('id', $module_id)->where('module_leader', $user_id)->exists() and Activity::where('id', $act_id)->where('module_id', $module_id)->exists() and ActSession::where('id', $sess_id)->where('activity_id', $act_id)->exists()) {
         $Session = ActSession::where('id', $sess_id)->where('activity_id', $act_id);
         $Session->delete();
         Session::flash('success', "Session was successfully deleted");
         return redirect('Lecturer/' . $user_id . '/Modules/mod' . $module_id . '/Act' . $act_id);
     } else {
         Session::flash('failed', "Something went wrong!, please try again or contact Technical Support");
         return back()->withInput();
     }
 }
Esempio n. 20
0
 });
 Route::post('login', function (Request $request) {
     $idnum = $request->input('idnum');
     $student = Student::findByIdnumOrFail($idnum);
     if ($student != null) {
         Session::put('student_id', $student->id);
         return redirect('choose');
     }
     return redirect('/');
 });
 Route::get('/choose', function (Request $request) {
     $student = Student::loggedIn();
     if (empty($student)) {
         return redirect('/');
     }
     $activities = Activity::where('sex', '=', $student->sex)->orWhere('sex', '=', 2)->get();
     return View::make('choose')->with(compact('student', 'activities'));
 });
 Route::post('/choose', function (Request $request) {
     $a1 = Input::get('a1');
     $a2 = Input::get('a2');
     if ($a1 == null || $a2 == null) {
         Session::flash('error', 'לא סימנת שתי פעילויות');
     } else {
         $student = Student::loggedIn();
         $oldA1 = $student->a1;
         $oldA2 = $student->a2;
         $student->a1 = $a1;
         $student->a2 = $a2;
         if (($student->a1->a1Available || ($oldA1 = $a1)) && ($student->a2->a2Available || ($oldA2 = $a2))) {
             if ($student->save()) {
Esempio n. 21
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return Activity::where('status', "!=", 'deleted')->get();
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\ActivityEditRequest $request, $id)
 {
     $data = $request->all();
     $act = Activity::where('name', '=', $request->get('name'))->whereNotIn('id', [$request->get('id')])->first();
     if ($act != null) {
         return response()->json('exists');
     } else {
         $actividad = Activity::find($id);
         $actividad->fill($data);
         $actividad->save();
         $activities = Activity::leftJoin('activity_stage', 'activity_stage.activity_id', '=', 'activities.id')->leftJoin('stages', 'stages.id', '=', 'activity_stage.stage_id')->leftJoin('desing_stage', 'desing_stage.stage_id', '=', 'stages.id')->leftJoin('designs', 'designs.id', '=', 'desing_stage.desing_id')->leftJoin('projects', 'projects.desing_id', '=', 'designs.id')->orderBy('activities.name', 'ASC')->groupBy('activities.id')->get(['activities.*', DB::raw("GROUP_CONCAT(stages.name SEPARATOR ',') AS stage_name"), DB::raw("GROUP_CONCAT(projects.name SEPARATOR ',') AS name_project")]);
         return response()->json(['activiteis' => $activities, 'valid' => true]);
     }
 }
Esempio n. 23
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     $cerf = Cerf::find($id);
     if (!(Auth::user()->hasRole('Officer') || Auth::user()->hasRole('Administrator') || Auth::id() === $cerf->user_id)) {
         redirect()->action('CerfsController@overview');
     }
     $activities = Activity::where('cerf_id', $cerf->id)->get();
     $kiwanisAttendees = KiwanisAttendee::where('cerf_id', $cerf->id)->get();
     $serviceHoursSum = $activities->sum('service_hours') + $activities->sum('planning_hours') + $activities->sum('traveling_hours');
     $adminHoursSum = $activities->sum('admin_hours');
     $socialHoursSum = $activities->sum('social_hours');
     $event = $cerf->event;
     $tagCategories = [];
     for ($index = 1; $index <= 4; $index++) {
         $currentTags = [];
         $tags = $event->tags()->where('cerf_id', $cerf->id)->where('category_id', $index)->get();
         foreach ($tags as $tag) {
             array_push($currentTags, $tag->name . ' (' . $tag->abbreviation . ')');
         }
         $tagCategories[EventCategory::find($index)->name] = $currentTags;
     }
     $drivers = [];
     foreach ($activities as $activity) {
         if ($activity->mileage > 0) {
             $drivers[$activity->name] = $activity->mileage;
         }
     }
     return view('pages.cerfs.show', compact('cerf', 'activities', 'kiwanisAttendees', 'serviceHoursSum', 'adminHoursSum', 'socialHoursSum', 'tagCategories', 'drivers'));
 }
Esempio n. 24
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $activity = Activity::where("id", "=", $id)->with('activityType', 'plant.plot')->first();
     //
     return $activity;
 }
 public function index(Request $request)
 {
     // Handles requests such as ".../api/activities?agenda_id=1&type=someType"
     return response(Activity::where($request->toArray())->get());
 }
 /**
  * Retrieves the filters for activity search.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return  JSON  array of filtered search with activity IDs
  */
 public function retrieveFilter(Request $request)
 {
     if ($request->get('filter') == null) {
         $status = ["Missing parameter"];
         return response()->json(compact('status'));
     } else {
         $filter = $request->get('filter');
         if ($filter == 'start') {
             if ($request->get('token') != null) {
                 $authenticatedUser = JWTAuth::setToken($request->get('token'))->authenticate();
                 $id = $authenticatedUser->volunteer_id;
                 $limit = $request->get('limit');
                 $approvedActivities = Activity::with('tasks')->whereHas('tasks', function ($query) {
                     $query->where('approval', 'like', 'approved');
                 })->lists('activity_id');
                 $appliedActivities = Task::Where('volunteer_id', '=', $id)->where(function ($query) {
                     $query->where('approval', '=', 'rejected')->orWhere('approval', '=', 'pending');
                 })->lists('activity_id');
                 $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                 $activityList = Activity::whereNotIn('activity_id', $notApproved)->groupBy('location_from_id')->lists('location_from_id');
                 $toReturn = [];
                 foreach ($activityList as $location) {
                     $locationName = Centre::findOrFail($location)->name;
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->whereNotIn('activity_id', $approvedActivities)->whereNotIn('activity_id', $appliedActivities)->whereNotIn('activity_id', $notApproved)->where('location_from_id', $location)->distinct()->lists('activity_id');
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["location_from" => $locationName, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
                 }
                 return response()->json($toReturn);
             } else {
                 $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                 $activityList = Activity::whereNotIn('activity_id', $notApproved)->groupBy('location_from_id')->lists('location_from_id');
                 $toReturn = [];
                 foreach ($activityList as $location) {
                     $locationName = Centre::findOrFail($location)->name;
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->whereNotIn('activity_id', $notApproved)->where('location_from_id', $location)->distinct()->lists('activity_id');
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["location_from" => $locationName, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
                 }
                 return response()->json($toReturn);
             }
         } elseif ($filter == 'end') {
             if ($request->get('token') != null) {
                 $authenticatedUser = JWTAuth::setToken($request->get('token'))->authenticate();
                 $id = $authenticatedUser->volunteer_id;
                 $limit = $request->get('limit');
                 $approvedActivities = Activity::with('tasks')->whereHas('tasks', function ($query) {
                     $query->where('approval', 'like', 'approved');
                 })->lists('activity_id');
                 $appliedActivities = Task::Where('volunteer_id', '=', $id)->where(function ($query) {
                     $query->where('approval', '=', 'rejected')->orWhere('approval', '=', 'pending');
                 })->lists('activity_id');
                 $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                 $notcompleted = Task::where('status', '=', 'completed')->distinct()->lists('activity_id');
                 $activityList = Activity::groupBy('location_to_id')->lists('location_to_id');
                 $toReturn = [];
                 $locationNameString = "";
                 $locationIdString = "";
                 foreach ($activityList as $location) {
                     $locationName = Centre::findOrFail($location)->name;
                     //echo $location;
                     $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->whereNotIn('activity_id', $approvedActivities)->whereNotIn('activity_id', $appliedActivities)->where('location_to_id', $location)->whereNotIn('activity_id', $notApproved)->distinct()->lists('activity_id');
                     //$stringToTitle = 'location_to';
                     $stringToList = $locationName . ' ' . $locationList;
                     //$locationNameString = $locationNameString . ',' .  $locationName;
                     //$locationIdString = $locationIdString . ',' . $locationList;
                     //$toReturn = array();
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["location_to" => $locationName, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
                 }
                 return response()->json($toReturn);
             } else {
                 $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                 $notcompleted = Task::where('status', '=', 'completed')->distinct()->lists('activity_id');
                 $activityList = Activity::groupBy('location_to_id')->lists('location_to_id');
                 $toReturn = [];
                 $locationNameString = "";
                 $locationIdString = "";
                 foreach ($activityList as $location) {
                     $locationName = Centre::findOrFail($location)->name;
                     //echo $location;
                     $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->where('location_to_id', $location)->whereNotIn('activity_id', $notApproved)->distinct()->lists('activity_id');
                     //$stringToTitle = 'location_to';
                     $stringToList = $locationName . ' ' . $locationList;
                     //$locationNameString = $locationNameString . ',' .  $locationName;
                     //$locationIdString = $locationIdString . ',' . $locationList;
                     //$toReturn = array();
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["location_to" => $locationName, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
                 }
                 return response()->json($toReturn);
             }
         } else {
             if ($request->get('token') != null) {
                 $authenticatedUser = JWTAuth::setToken($request->get('token'))->authenticate();
                 $id = $authenticatedUser->volunteer_id;
                 $limit = $request->get('limit');
                 $approvedActivities = Activity::with('tasks')->whereHas('tasks', function ($query) {
                     $query->where('approval', 'like', 'approved');
                 })->lists('activity_id');
                 $appliedActivities = Task::Where('volunteer_id', '=', $id)->where(function ($query) {
                     $query->where('approval', '=', 'rejected')->orWhere('approval', '=', 'pending');
                 })->lists('activity_id');
                 $activityList = Activity::groupBy('datetime_start')->lists('datetime_start');
                 $toReturn = [];
                 foreach ($activityList as $dateTimeStart) {
                     $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->whereNotIn('activity_id', $approvedActivities)->whereNotIn('activity_id', $appliedActivities)->whereNotIn('activity_id', $notApproved)->where('datetime_start', '=', $dateTimeStart)->whereNotIn('activity_id', $notApproved)->distinct()->lists('activity_id');
                     //$toReturn = array();
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["time" => $dateTimeStart, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
                 }
                 return response()->json($toReturn);
             } else {
                 $activityList = Activity::groupBy('datetime_start')->lists('datetime_start');
                 $toReturn = [];
                 foreach ($activityList as $dateTimeStart) {
                     $notApproved = Task::where('approval', '=', 'approved')->distinct()->lists('activity_id');
                     $locationList = Activity::where('datetime_start', '>', Carbon::now())->whereNotIn('activity_id', $notApproved)->where('datetime_start', '=', $dateTimeStart)->whereNotIn('activity_id', $notApproved)->distinct()->lists('activity_id');
                     //$toReturn = array();
                     if (!$locationList->isEmpty()) {
                         array_push($toReturn, ["time" => $dateTimeStart, "activity_ids" => implode(",", $locationList->toArray())]);
                     }
                 }
                 return response()->json($toReturn);
             }
         }
     }
 }
Esempio n. 27
0
 public function activity()
 {
     if ($this->data['user']['level'] > 1) {
         $this->data['activities'] = Activity::orderBy('created_at', 'desc')->paginate('10');
     } else {
         $this->data['activities'] = Activity::where('user', $this->data['user']['id'])->where('level', 0)->orderBy('created_at', 'desc')->paginate('10');
     }
     return view('home.activity', $this->data);
 }
 public function getRecord($id)
 {
     if (Request::ajax()) {
         return Activity::where('student_id', $id)->get();
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete()
 {
     $film_id = Input::get('film');
     $query = DB::table('user_fav')->where('fav_fl_id', '=', $film_id)->where('fav_usr_id', '=', Auth::user()->id)->delete();
     Activity::where('object_id', $film_id)->where('type_id', '5')->where('subject_id', Auth::user()->id)->where('object_type', 'film')->delete();
     if ($query) {
         return 'true';
     } else {
         return 'false';
     }
 }
 public function ReqAct($user_id, $module_id)
 {
     if (UserMod::where('id', $user_id)->where('role', '=', 'PHD Student')->exists() and Module::where('id', $module_id)->exists()) {
         if (AddRequest::where('user_id', '=', Input::get('user_id'))->where('activity_id', '=', Input::get('activity_id'))->exists()) {
             Session::flash('ErrMessage', "You already have requested this activity before");
             return back()->withInput();
         } else {
             $supervisor_id = Input::get('supervisor');
             $supervisor = UserMod::where('id', $supervisor_id)->where('role', '=', 'Lecturer')->first();
             $activity_id = Input::get('activity_id');
             $activity = Activity::where('id', $activity_id)->with('module')->first();
             $messageSubject = '[No reply] Application Requested';
             $user = UserMod::where('id', $user_id)->where('role', '=', 'PHD Student')->first();
             $student_name = $user->name;
             $student_email = $user->email;
             $activity_title = $activity->title;
             $activity_module = $activity->module->module_code . ' ' . $activity->module->module_name;
             AddRequest::create(array('activity_id' => Input::get('activity_id'), 'user_id' => Input::get('user_id'), 'status' => Input::get('status')));
             $supervisor_name = $supervisor->title . '. ' . $supervisor->name;
             $supervisor_email = $supervisor->email;
             // Sending Email to PhD Student when requesting job
             $data = array('name' => $student_name, 'Recemail' => $student_email, 'activity_title' => $activity_title, 'activity_module' => $activity_module);
             Mail::send('PhdApplicationRequest', $data, function ($message) use($student_email, $student_name, $messageSubject) {
                 $message->to($student_email, $student_name)->subject($messageSubject);
             });
             // Sending Email to Supervisor for confirmation
             $sup_mail = array('name' => $supervisor_name, 'Recemail' => $supervisor_email, 'student_name' => $student_name, 'activity_title' => $activity_title, 'activity_module' => $activity_module);
             Mail::send('LecturerApplicationRequest', $sup_mail, function ($message) use($supervisor_email, $supervisor_email, $messageSubject) {
                 $message->to($supervisor_email, $supervisor_email)->subject($messageSubject);
             });
             Session::flash('message', "Request was successfully sent!, an email was sent to you showing your application's details");
             return back()->withInput();
         }
     } else {
         Session::flash('failed', "Something went wrong, please try again!");
         return back()->withInput();
     }
 }