12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Http\Services;
- use Illuminate\Support\Facades\Http;
- use Illuminate\Support\Facades\View;
- use App\Models\Survey;
- use App\Models\Client;
- class SurveyService
- {
- public $internalName;
- public $defaultHTML;
- public function __construct($internalName)
- {
- $this->internalName = $internalName;
- $surveyFormPath = resource_path(Survey::FORM_PATH . '/' . $this->internalName . '.blade.php');
- if(file_exists($surveyFormPath)){
- $this->defaultHTML = (string) view('app.patient.surveys.forms.templates.'.$this->internalName);
- }
- }
- public function getInitializedData($entityType, $entityUid){
- if($this->internalName === 'sleep'){
- if($entityType === 'Client'){
- $client = Client::where('uid', $entityUid)->first();
- if($client){
- return [
- 'nameFirst' => $client->name_first,
- 'nameMiddle' => $client->name_middle,
- 'nameLast' => $client->name_last,
- 'description' => null
- ];
- }
- }
- }
- return null;
- }
- }
|