HrSectionChange.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Models;
  3. # use Illuminate\Database\Eloquent\Model;
  4. class HrSectionChange extends Model
  5. {
  6. protected $table = 'hr_section_change';
  7. public function hrSection()
  8. {
  9. return $this->hasOne(HrSection::class, 'id', 'hr_section_id');
  10. }
  11. public function getOldValue(){
  12. switch($this->change_type){
  13. case 'DATA': return $this->old_data;
  14. case 'STATUS': return $this->old_status;
  15. case 'PROPOSED_DATA': return $this->old_proposed_data;
  16. case 'PROPOSED_STATUS': return $this->old_proposed_status;
  17. default:
  18. return 'Unknown change type';
  19. }
  20. }
  21. public function getNewValue(){
  22. switch($this->change_type){
  23. case 'DATA': return $this->new_data;
  24. case 'STATUS': return $this->new_status;
  25. case 'PROPOSED_DATA': return $this->new_proposed_data;
  26. case 'PROPOSED_STATUS': return $this->new_proposed_status;
  27. default:
  28. return 'Unknown change type';
  29. }
  30. }
  31. }