コード例 #1
0
ファイル: DatabaseSeeder.php プロジェクト: strikles/php
 public function run()
 {
     // users
     DB::table('users')->delete();
     $user = \App\User::create(['first_name' => 'Claudio', 'last_name' => 'Neto', 'name' => 'Claudio Neto', 'photo' => 'images/icons/default_user.png', 'company_name' => 'eenvoudmedia', 'company_address' => 'van diemenstraat', 'company_zip' => '1013', 'company_city' => 'amsterdam', 'company_country' => 'Netherlands', 'company_website' => 'www.eenvoudmedia.nl', 'confirmed' => '1', 'birthdate' => '1978-08-04', 'email' => '*****@*****.**', 'password' => bcrypt('xxx')]);
     // groups
     DB::table('groups')->delete();
     $group = \App\Group::create(['name' => 'eenvoudmedia', 'description' => 'Test Group', 'photo' => 'images/icons/default_group.png', 'website' => 'www.eenvodmedia.nl', 'country' => 'netherlands', 'city' => 'amsterdam', 'language' => 'dutch', 'meeting_time' => '17:00', 'meeting_weekday' => 5, 'chairman_id' => $user->id]);
     // attach user to group 1
     $user->groups()->attach($group->id);
     // make user an admin
     $user->roles()->attach(1);
     // create a past group meeting
     DB::table('groupmeetings')->delete();
     $gm = \App\Groupmeeting::create(['group_id' => $group->id, 'meeting_date' => '2015-03-19 22:00']);
     // user attended meeting
     DB::table('groupmeetingattendees')->delete();
     \App\Groupmeetingattendees::create(['meeting_id' => $gm->id, 'user_id' => $user->id]);
 }
コード例 #2
0
ファイル: DashboardController.php プロジェクト: strikles/php
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $bodyclass = "app-dashboard";
     $user = \Auth::user();
     $user_groups = $user->groups()->get();
     $user_meetings_attended = \App\Groupmeetingattendees::where('user_id', $user->id)->get();
     $past_activities = [];
     $future_activities = [];
     foreach ($user_meetings_attended as $key => $uattended) {
         $group_meeting = \App\Groupmeeting::find($uattended->meeting_id);
         if ($group_meeting) {
             error_log('Date AM - ' . $group_meeting->meeting_date . ' - ' . date("Y-m-d H:i:s", strtotime($group_meeting->meeting_date)) . ' - ' . date("Y-m-d H:i:s", strtotime('now')));
             // past
             if (strtotime($group_meeting->meeting_date) < strtotime('now')) {
                 $past_activities[] = $group_meeting;
             } else {
                 $future_activities[] = $group_meeting;
             }
         }
     }
     // error_log(json_encode($user));
     // error_log(json_encode($user_groups));
     return view('site.dashboard.index', compact('bodyclass', 'user', 'user_groups', 'past_activities', 'future_activities'));
 }
コード例 #3
0
ファイル: GroupsController.php プロジェクト: strikles/php
 public function attendMeeting($group)
 {
     // next meeting date
     $next_meeting_date = date(date('Y-m-d', strtotime('next ' . $group->weekdays[(int) $group->meeting_weekday])) . " " . $group->meeting_time);
     // check if a meeting entry exists for the next meeting date, if not create a new one
     $next_meeting = \App\Groupmeeting::firstOrCreate(['group_id' => $group->id, 'meeting_date' => $next_meeting_date]);
     if (!$next_meeting) {
         error_log("Could not find or create a meeting for the {$group->name} group");
         throw new \Exception("Could not find or create a meeting for the {$group->name} group");
     }
     // add entry if one doesn't exist yet
     $user = \Auth::user();
     $user_attendance = \App\Groupmeetingattendees::firstOrCreate(['meeting_id' => $next_meeting->id, 'user_id' => $user->id]);
     if (!$user_attendance) {
         error_log("Could not find or create a meeting attendance entry for the {$group->name} group");
         throw new \Exception("Could not find or create a meeting attendance entry for the {$group->name} group");
     }
     return redirect("/dashboard");
 }