| xqd | @@ -2,6 +2,7 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  namespace App\Models;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +use Carbon\Carbon;
 | 
	
		
			
				|  |  |  use Illuminate\Database\Eloquent\Model;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  class StudentCourse extends Model
 | 
	
	
		
			
				| xqd | @@ -69,4 +70,17 @@ class StudentCourse extends Model
 | 
	
		
			
				|  |  |              ]);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function computeEndDate()
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        $apply_date = $this['apply_date'];
 | 
	
		
			
				|  |  | +        if(empty($apply_date) || empty($this['duration'])) {
 | 
	
		
			
				|  |  | +            return '';
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            $days = $this['duration'];
 | 
	
		
			
				|  |  | +            $leave_days = (int)Leave::where('student_id', $this['id'])->get()->count('days');
 | 
	
		
			
				|  |  | +            $days += $leave_days;
 | 
	
		
			
				|  |  | +            return Carbon::createFromTimestamp(strtotime($apply_date))->addDays($days)->toDateString();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |