|
|
@@ -15,6 +15,7 @@ use Exception;
|
|
|
* @property int $type
|
|
|
* @property string $price
|
|
|
* @property string $url
|
|
|
+ * @property int $archived
|
|
|
*/
|
|
|
|
|
|
class Product extends Model implements \JsonSerializable {
|
|
|
@@ -23,7 +24,7 @@ class Product extends Model implements \JsonSerializable {
|
|
|
protected static $idField = "id";
|
|
|
protected static $fillableFields = [
|
|
|
"supplier_id",
|
|
|
- "name", "type", "sku", "price", "url",
|
|
|
+ "name", "type", "sku", "price", "url", "archived",
|
|
|
"dts_created", "dts_updated", "dts_deleted"
|
|
|
];
|
|
|
|
|
|
@@ -75,6 +76,10 @@ class Product extends Model implements \JsonSerializable {
|
|
|
return sprintf("/products/%s", $this->getSlug());
|
|
|
}
|
|
|
|
|
|
+ public function getUpdateUrl(): string {
|
|
|
+ return sprintf("/products/%s/update", $this->getSlug());
|
|
|
+ }
|
|
|
+
|
|
|
public function getWebsiteUrl(): ?string {
|
|
|
return $this->url;
|
|
|
}
|
|
|
@@ -95,6 +100,7 @@ class Product extends Model implements \JsonSerializable {
|
|
|
"sku" => $this->sku,
|
|
|
"type" => (int) $this->type,
|
|
|
"price" => $this->price,
|
|
|
+ "archived" => $this->isArchived(),
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -109,4 +115,8 @@ class Product extends Model implements \JsonSerializable {
|
|
|
public function deleteBrochure(): bool {
|
|
|
return !$this->hasBrochure() || unlink($this->getBrochurePath());
|
|
|
}
|
|
|
+
|
|
|
+ public function isArchived(): bool {
|
|
|
+ return (bool) $this->archived;
|
|
|
+ }
|
|
|
}
|