예제 #1
0
 function make($data)
 {
     $month = Month::ForMonth('January')->first();
     $config['month_id'] = $month->id;
     $config['member_id'] = Session::get('memberId');
     $config['date'] = $data['date'];
     if (array_key_exists('check_in', $data)) {
         $config['check_in'] = $data['check_in'];
         $attendance = Attendance::ForUniqueCheck($config['member_id'], $config['date'])->first();
         if (empty($attendance)) {
             Attendance::create($config);
         } else {
             throw new Exception('You Already have check In for the day');
         }
     }
     if (array_key_exists('check_out', $data)) {
         $config['check_out'] = $data['check_out'];
         //        foreach($data as  $key => $value)
         //        {
         //            $this->is_empty($value);
         //        }
         //        $this->is_valid($this->checkInFlag);
         $attendance = Attendance::ForUniqueCheck($config['member_id'], $config['date'])->first();
         if (empty($attendance)) {
             throw new Exception('You Havent check in yet');
         }
         if ($attendance->check_out === '00:00:00') {
             $attendance->update($data);
         } else {
             throw new Exception('You Already have check out for the day');
         }
     }
 }
 public function setUp()
 {
     parent::setUp();
     $this->user = \App\User::create(['name' => '*****@*****.**', 'email' => '*****@*****.**', 'password' => 'test']);
     $this->group = \App\CustomerGroup::create(['groupname' => 'Group 1']);
     $customer = \App\Customer::create(['firstname' => 'John', 'lastname' => 'Doe', 'phone' => '01234567891', 'group_id' => $this->group->id, 'email' => '*****@*****.**', 'birthday' => '1990-01-01']);
     $this->customers[] = $customer;
     $customer = \App\Customer::create(['firstname' => 'John', 'lastname' => 'Resig', 'phone' => '01234567891', 'group_id' => $this->group->id, 'email' => '*****@*****.**', 'birthday' => '1990-01-01']);
     $this->customers[] = $customer;
     $customer = \App\Customer::create(['firstname' => 'Taylor', 'lastname' => 'Otwell', 'phone' => '01234567891', 'group_id' => $this->group->id, 'email' => '*****@*****.**', 'birthday' => '1990-01-01']);
     $this->customers[] = $customer;
     foreach ($this->customers as $customer) {
         $customer->save();
     }
     $this->attendance[] = \App\Attendance::create(['group_id' => $this->group->id, 'customer_id' => $this->customers[0]->id, 'was_at' => new Carbon\Carbon('2015-01-01')]);
     $this->attendance[] = \App\Attendance::create(['group_id' => $this->group->id, 'customer_id' => $this->customers[1]->id, 'was_at' => new Carbon\Carbon('2015-01-01')]);
     $this->attendance[] = \App\Attendance::create(['group_id' => $this->group->id, 'customer_id' => $this->customers[2]->id, 'was_at' => new Carbon\Carbon('2015-01-01')]);
 }
예제 #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $attendanceStudent = Attendance::create(['attendance' => $request->attendance, 'student_id' => $request->student_id]);
     $attendanceUser = AttendanceUser::create(['attendance' => $request->attendance, 'user_id' => $request->user_id]);
     return redirect('principal/classroom#attendance-tab')->withInput();
 }
 public function store(RecordAttendance $request)
 {
     Attendance::create($request->all());
 }
예제 #5
0
 /**
  *
  */
 public function run()
 {
     $faker = Faker::create();
     $eventIds = Event::lists('id');
     $userIds = User::lists('id');
     foreach (range(1, 200) as $index) {
         Attendance::create(['user_id' => $faker->randomElement($userIds), 'event_id' => $faker->randomElement($eventIds)]);
     }
 }