| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace App;
- use App\Interfaces\CommentInterface;
- use App\Traits\DateTimeTrait;
- use App\Traits\SoftDeleteTrait;
- use Exception;
- /**
- * @property int $id
- * @property int $sale_id
- * @property int $user_id
- * @property string $content
- */
- class SaleNote extends Model implements CommentInterface, \JsonSerializable {
- protected static $table = "sale_note";
- protected static $idField = "id";
- protected static $fillableFields = [
- "sale_id", "user_id",
- "content",
- "dts_created", "dts_updated", "dts_deleted",
- ];
- use DateTimeTrait;
- use SoftDeleteTrait;
- /**
- * @return User
- * @throws Exception
- */
- public function getUser(): User {
- return User::get($this->user_id);
- }
- public function isInternal(): bool {
- return false;
- }
- public function getAttachments(): array {
- return [];
- }
- public function getHtml(): string {
- return nl2br(htmlspecialchars($this->content));
- }
- /**
- * @return void
- * @throws Exception
- */
- public function renderEditIcon(): void {
- ?>
- <a href="#" data-bs-toggle="modal" data-bs-target="#sale-note-modal" data-sale-number="<?=$this->getSale()->getNumber()?>" data-note="<?=htmlspecialchars(json_encode($this))?>">
- <i class="fa fa-fw fa-pencil"></i>
- </a>
- <?php
- }
- /**
- * @return Sale
- * @throws Exception
- */
- public function getSale(): Sale {
- return Sale::get($this->sale_id);
- }
- public function jsonSerialize(): array {
- return [
- "id" => (int) $this->id,
- "content" => $this->content
- ];
- }
- }
|