| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App;
- use App\Traits\DateTimeTrait;
- use App\Traits\SoftDeleteTrait;
- use JsonSerializable;
- /**
- * @property int $id
- * @property int $document_id
- * @property string $description
- * @property string $serial_number
- * @property int $quantity
- * @property string $unit_price
- */
- class DocumentItem extends Model implements JsonSerializable {
- protected static $table = "document_item";
- protected static $idField = "id";
- protected static $fillableFields = [
- "document_id",
- "description", "serial_number",
- "quantity", "unit_price",
- "dts_created", "dts_updated", "dts_deleted"
- ];
- use DateTimeTrait;
- use SoftDeleteTrait;
- // Object methods
- public function getAmount(): string {
- return bcmul($this->unit_price, $this->quantity, 2);
- }
- public function jsonSerialize(): array {
- return [
- "id" => (int) $this->id,
- "documentId" => (int) $this->document_id,
- "description" => $this->description,
- "serialNumber" => $this->serial_number,
- "quantity" => (int) $this->quantity,
- "unitPrice" => $this->unit_price,
- ];
- }
- }
|