<?php

use App\Models\Client;
use App\Models\Note;

use App\Models\Page;

$page = Page::where('client_id', $patient->id)->where('category', 'CANVAS')->where('key', 'cc_may21')->first();

/** @var Client $patient */
/** @var Note $note */

if(!@$contentData) {
    $contentData = [
        "text" => '',
        "was_confirmed" => false,
        "note_uid" => (@$note ? $note->uid : '')
    ];

    if($page){
        $contentData = json_decode($page->data, true);
    }else{
        if ($patient->canvas_data) {
            $canvasData = json_decode($patient->canvas_data, true);
            if (isset($canvasData["cc_may21"])) {
                $contentData = $canvasData["cc_may21"];
                if (!isset($contentData['text'])) $contentData['text'] = '';
                if (!isset($contentData['was_confirmed'])) $contentData['was_confirmed'] = false;
            }
        }
    }
}
?>

<p><?= $contentData['text'] ? $contentData['text'] : '-' ?></p>
