Survey.php 567 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Models;
  3. class Survey extends Model
  4. {
  5. protected $table = 'survey';
  6. const FORM_PATH = "views/app/patient/surveys/forms/templates";
  7. const ALLOWED_ENTITIES = [
  8. 'Client',
  9. ];
  10. public function getFieldValue($field){
  11. $data = json_decode($this->survey_data);
  12. return @$data->{$field};
  13. }
  14. public function getEntity(){
  15. $entity = null;
  16. if($this->entity_type === 'Client'){
  17. $entity = Client::where('uid', $this->entity_uid)->first();
  18. }
  19. return $entity;
  20. }
  21. }