update
This commit is contained in:
		
							parent
							
								
									da19bb89fc
								
							
						
					
					
						commit
						c8722e6b10
					
				| 
						 | 
				
			
			@ -79,6 +79,7 @@ class TrackingController extends Controller
 | 
			
		|||
            if ($user) {
 | 
			
		||||
                $payload['user_id'] = $user->id;
 | 
			
		||||
                $latest = Tracking::where('name', $payload['name'])->latest()->first();
 | 
			
		||||
                if($latest){
 | 
			
		||||
                    if($payload['status'] == $this->CHECK_IN || $payload['status'] == $this->CHECK_OUT){
 | 
			
		||||
                        if ($latest->status == $this->CHECK_IN) {
 | 
			
		||||
                            $payload['status'] = $this->CHECK_OUT;
 | 
			
		||||
| 
						 | 
				
			
			@ -98,6 +99,15 @@ class TrackingController extends Controller
 | 
			
		|||
                            'status' => false
 | 
			
		||||
                        ]);
 | 
			
		||||
                    }
 | 
			
		||||
                }else{
 | 
			
		||||
                    $tracking = Tracking::create($payload);
 | 
			
		||||
                        return response()->json([
 | 
			
		||||
                            'data' => $tracking,
 | 
			
		||||
                            'check_status' => $payload['status'],
 | 
			
		||||
                            'status' => true
 | 
			
		||||
                        ]);
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return response()->json([
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue